﻿using System;
using System.Data;
using System.Text;
using System.Collections.Generic;
using System.Data.OracleClient;
namespace GSLMS.DAL.Oracle
{
	/// <summary>
	/// 数据访问类:APP_PROINFO
	/// </summary>
	public partial class APP_PROINFO : BaseDAL<GSLMS.Entity.TB_APP_PROINFO>
	{
		private readonly GSLMS.Core.Loger log = new Core.Loger();
		public APP_PROINFO()
		{}
		#region  Method
		/// <summary>
		///  增加一条数据
		/// </summary>
		public override bool Add(GSLMS.Entity.TB_APP_PROINFO model)
		{
			bool flag = false;
            int num = 0;
            model.APPDATE = Convert.ToDateTime(model.APPDATE.ToString());

            OracleParameter[] parms = new OracleParameter[]{
								new OracleParameter("P_ID", OracleType.Number),
								new OracleParameter("P_REGINFOID", model.REGINFOID),
								new OracleParameter("P_CUSTNAME", model.CUSTNAME),
								new OracleParameter("P_DOCTYPE", model.DOCTYPE),
								new OracleParameter("P_DOCTYPENAME", model.DOCTYPENAME),
								new OracleParameter("P_CUSTNO", model.CUSTNO),
								new OracleParameter("P_APPLYNO", model.APPLYNO==null?"":model.APPLYNO),
								new OracleParameter("P_APPDATE",model.APPDATE),
								new OracleParameter("P_LOANTYPE", model.LOANTYPE),
								new OracleParameter("P_SALESMANID", model.SALESMANID),

								new OracleParameter("P_SALESMAN", model.SALESMAN==null?"":model.SALESMAN),
								new OracleParameter("P_DEPID", model.DEPID),
								new OracleParameter("P_DEPNAME", model.DEPNAME),
								new OracleParameter("P_BUSSTYPE", model.BUSSTYPE),
								new OracleParameter("P_PRODUCTID", model.PRODUCTID),
								new OracleParameter("P_PRODUCTNAME", model.PRODUCTNAME),
								new OracleParameter("P_MEDIATORID", model.MEDIATORID),
								new OracleParameter("P_MEDIATOR", model.MEDIATOR==null?"":model.MEDIATOR),
								new OracleParameter("P_MEDIATORACCOUNT", model.MEDIATORACCOUNT==null?"":model.MEDIATORACCOUNT),
								new OracleParameter("P_MEDIATORTEL", model.MEDIATORTEL==null?"":model.MEDIATORTEL),

								new OracleParameter("P_SOURCE", model.SOURCE==null?"":model.SOURCE),
								new OracleParameter("P_ISSPECIAL", model.ISSPECIAL),
								new OracleParameter("P_SPECID", model.SPECID),
								new OracleParameter("P_CONTACT", model.CONTACT==null?"":model.CONTACT),
								new OracleParameter("P_CONTRACTTEL", model.CONTRACTTEL==null?"":model.CONTRACTTEL),
								new OracleParameter("P_CONTRACTTEL2", model.CONTRACTTEL2==null?"":model.CONTRACTTEL2),
								new OracleParameter("P_AMOUNT", model.AMOUNT),
								new OracleParameter("P_LOANPHASE", model.LOANPHASE),
								new OracleParameter("P_LOANPHAESTYPE", model.LOANPHAESTYPE),
								new OracleParameter("P_RATE", model.RATE),
                             
								new OracleParameter("P_MANAGEFEERATE", model.MANAGEFEERATE),
								new OracleParameter("P_GENERALRATE", model.GENERALRATE),
								new OracleParameter("P_LOANFEE", model.LOANFEE),
								new OracleParameter("P_STATUS", model.STATUS),
								new OracleParameter("P_CANCELBY", model.CANCELBY==null?"":model.CANCELBY),
								new OracleParameter("P_CANCELDATE", model.CANCELDATE),
								new OracleParameter("P_CANCELREASON", model.CANCELREASON==null?"":model.CANCELREASON),
								new OracleParameter("P_BACKSTATUS", model.BACKSTATUS),
								new OracleParameter("P_BACKDATE", model.BACKDATE),
								new OracleParameter("P_BACKBY", model.BACKBY==null?"":model.BACKBY),

								new OracleParameter("P_BACKREASON", model.BACKREASON==null?"":model.BACKREASON),
								new OracleParameter("P_FLOWSTATUS", model.FLOWSTATUS),
								new OracleParameter("P_SYSTEMID", model.SYSTEMID),
								new OracleParameter("P_SITENO", model.SITENO==null?"":model.SITENO),
								new OracleParameter("P_SITENAME", model.SITENAME==null?"":model.SITENAME),
								new OracleParameter("P_SITEID", model.SITEID),
								new OracleParameter("P_SPAREFIELD1", model.SPAREFIELD1==null?0:model.SPAREFIELD1),
								new OracleParameter("P_SPAREFIELD2", model.SPAREFIELD2==null?"":model.SPAREFIELD2),
								new OracleParameter("P_SPAREFIELD3", model.SPAREFIELD3==null?"":model.SPAREFIELD3)
                             };


            parms[0].Direction = ParameterDirection.Output;
			for (int i = 1; i < 49; i++)
			{
				parms[i].Direction = ParameterDirection.Input;
			}

            OracleConnection con = new OracleConnection(OracleHelper.connectionString);
            con.Open();
            OracleTransaction tran = con.BeginTransaction();
            OracleCommand cmd = con.CreateCommand();
            cmd.Transaction = tran;

            try
            {


                cmd.Parameters.Clear();
                cmd.Parameters.AddRange(parms);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "pkg_apply.proc_proinfo_add";
                //保存主表信息
                 cmd.ExecuteNonQuery();
                long proID=0;

                if(parms[0].Value!=DBNull.Value)
                    proID=OracleHelper.ToLong(parms[0].Value.ToString());


                if (proID > 0)
                {

                    //保存非赎楼信息
                    if (model.ProUnForHouInfo != null)
                    {
                        if (!AddProUnForHouInfo(ref cmd, model.ProUnForHouInfo, proID))
                            num++;
                    }
                    //保存股东信息
                    if (model.ProShareHolderInfos != null && model.ProShareHolderInfos.Count > 0)
                    {
                        if (!AddSharHolderInfo(ref cmd, model.ProShareHolderInfos, proID))
                            num++;
                    }

                    //保存赎楼信息
                    if (model.ProForHouInfo != null)
                    {
                        if (!AddProForHouInfo(ref cmd, model.ProForHouInfo, proID))
                            num++;
                    }

                    

                    if (num == 0)
                    {
                        tran.Commit();
                        flag = true;
                    }
                    else
                    {
                        tran.Rollback();
                    }

                }
                
            }
            catch (Exception ex)
            {
                log.ExceptionHand(ex);
                tran.Rollback();
            }
            finally
            {
                cmd.Dispose();
                tran.Dispose();
                con.Close();
                con.Dispose();
            }
			return flag;
		}


        /// <summary>
        ///  保存非赎楼信息
        /// </summary>
        private bool AddProUnForHouInfo(ref OracleCommand cmd ,GSLMS.Entity.TB_APP_PROUNFORHOUINFO model,long procID)
        {
            bool flag = false;
            OracleParameter[] parms = new OracleParameter[]{
								new OracleParameter("P_ID", model.ID),
								new OracleParameter("P_PROCID", procID),
								new OracleParameter("P_REGINFOID", model.REGINFOID),
								new OracleParameter("P_RISKBYID", model.RISKBYID),
								new OracleParameter("P_RISKBYNAME", model.RISKBYNAME??""),
								new OracleParameter("P_LEGAL", model.LEGAL??""),
								new OracleParameter("P_LEGALTEL", model.LEGALTEL??""),
								new OracleParameter("P_LEGALTEL2", model.LEGALTEL2??""),
								new OracleParameter("P_CONBY", model.CONBY??""),
								new OracleParameter("P_CONBYTEL", model.CONBYTEL??""),
								new OracleParameter("P_CONBYTEL2", model.CONBYTEL2??""),
								new OracleParameter("P_CORPADDRESS", model.CORPADDRESS??""),
								new OracleParameter("P_REGAMOUNT", model.REGAMOUNT),
								new OracleParameter("P_MAINBUSS", model.MAINBUSS??""),
								new OracleParameter("P_REPAYMENT", model.REPAYMENT),
								new OracleParameter("P_USEFOR", model.USEFOR??""),
								new OracleParameter("P_ADVAMT", model.ADVAMT),
								new OracleParameter("P_BUSSBRIEF", model.BUSSBRIEF??""),
								new OracleParameter("P_LOANMODE", model.LOANMODE??""),
								new OracleParameter("P_REPAYSOURCE", model.REPAYSOURCE??""),
								new OracleParameter("P_SPAREFIELD1", model.SPAREFIELD1),
								new OracleParameter("P_SPAREFIELD2", model.SPAREFIELD2??""),
								new OracleParameter("P_SPAREFIELD3", model.SPAREFIELD3??"")};

            for (int i = 0; i < 23; i++)
            {
                parms[i].Direction = ParameterDirection.Input;
            }

            try
            {
                cmd.Parameters.Clear();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "pkg_apply.proc_ProUnForHouInfo";
                cmd.Parameters.AddRange(parms);
                int num = cmd.ExecuteNonQuery();
                if (num == 1)
                    flag = true;

            }
            catch (Exception ex)
            {
                log.ExceptionHand(ex);
            }
            return flag;
        }

        /// <summary>
        ///  增加股东信息
        /// </summary>
        private bool AddSharHolderInfo(ref OracleCommand cmd,List<GSLMS.Entity.TB_APP_SHAREHOLDERINFO> list,long proID)
        {
            bool flag = false;
            if (list != null && list.Count > 0)
            {
                foreach (var model in list)
                {
                    OracleParameter[] parms = new OracleParameter[]{
								new OracleParameter("P_ID", model.ID),
								new OracleParameter("P_REGINFOID", model.REGINFOID),
								new OracleParameter("P_PROID", proID),
								new OracleParameter("P_NAME", model.NAME??""),
								new OracleParameter("P_ADDRESS", model.ADDRESS??""),
								new OracleParameter("P_TEL", model.TEL??""),
								new OracleParameter("P_FUNDED", model.FUNDED??""),
								new OracleParameter("P_AMOUNT", model.AMOUNT),
								new OracleParameter("P_RATIO", model.RATIO),
								new OracleParameter("P_ISPAYED", model.ISPAYED),
								new OracleParameter("P_SPAREFIELD1", model.SPAREFIELD1),
								new OracleParameter("P_SPAREFIELD2", model.SPAREFIELD2??""),
								new OracleParameter("P_SPAREFIELD3", model.SPAREFIELD3??"")};

                    for (int i = 0; i < 13; i++)
                    {
                        parms[i].Direction = ParameterDirection.Input;
                    }

                    try
                    {
                        cmd.Parameters.Clear();
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.CommandText = "pkg_apply.proc_SharHoulderInfo_Add";
                        cmd.Parameters.AddRange(parms);
                        int num = cmd.ExecuteNonQuery();
                        if (num!=1)
                        {
                            return false;
                        }
                       
                    }
                    catch (Exception ex)
                    {
                        log.ExceptionHand(ex);
                    }
                }

                flag = true;

            }
            else
                flag = true;

            return flag;
        }

        /// <summary>
        ///  保存赎楼信息
        /// </summary>
        private bool AddProForHouInfo(ref OracleCommand cmd, GSLMS.Entity.TB_APP_PROFORHOUINFO model,long proID)
        {
            bool flag = false;
            OracleParameter[] parms = new OracleParameter[]{
								new OracleParameter("P_ID", model.ID),
								new OracleParameter("P_PROID", proID),
								new OracleParameter("P_REGINFOID", model.REGINFOID),
								new OracleParameter("P_TRADEBY", model.TRADEBY??""),
								new OracleParameter("P_FORHOUTYPE", model.FORHOUTYPE),
								new OracleParameter("P_BUSSTYPE", model.BUSSTYPE),
								new OracleParameter("P_HOUADD", model.HOUADD??""),
								new OracleParameter("P_TENRIGHT", model.TENRIGHT??""),
								new OracleParameter("P_TENBANK", model.TENBANK??""),
								new OracleParameter("P_TENSUBBACK", model.TENSUBBACK??""),
								new OracleParameter("P_TENENDDATE", model.TENENDDATE),
								new OracleParameter("P_TENLEFTAMT", model.TENLEFTAMT),
								new OracleParameter("P_HOUPRICE", model.HOUPRICE),
								new OracleParameter("P_HOUTOTALPRICE", model.HOUTOTALPRICE),
								new OracleParameter("P_DOWNPAYAMT", model.DOWNPAYAMT),
								new OracleParameter("P_FIRSTPAYAMT", model.FIRSTPAYAMT),
								new OracleParameter("P_PAYMOD", model.PAYMOD??""),
								new OracleParameter("P_PAYBANK", model.PAYBANK??""),
								new OracleParameter("P_PAYSUBBANK", model.PAYSUBBANK??""),
								new OracleParameter("P_PROMISEAMT", model.PROMISEAMT),
								new OracleParameter("P_COUGUA1", model.COUGUA1??""),
								new OracleParameter("P_VERIFILD1", model.VERIFILD1??""),
								new OracleParameter("P_COUGUA2", model.COUGUA2??""),
								new OracleParameter("P_VERIFILD2", model.VERIFILD2??""),
								new OracleParameter("P_SIGNMAN", model.SIGNMAN??""),
								new OracleParameter("P_SPAREFIELD1", model.SPAREFIELD1),
								new OracleParameter("P_SPAREFIELD2", model.SPAREFIELD2??""),
								new OracleParameter("P_SPAREFIELD3", model.SPAREFIELD3??"")};

            for (int i = 0; i < 28; i++)
            {
                parms[i].Direction = ParameterDirection.Input;
            }

            try
            {
                cmd.Parameters.Clear();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "pkg_apply.proc_ProForHouInfo";
                cmd.Parameters.AddRange(parms);
                int num = cmd.ExecuteNonQuery();
                if (num == 1)
                    flag = true;
            }
            catch (Exception ex)
            {
                log.ExceptionHand(ex);
            }
            return flag;
        }

        /// <summary>
        /// 新增风控审批信息
        /// </summary>
        /// <param name="?"></param>
        /// <returns></returns>
        public bool AddProRiskControlReportInfo(GSLMS.Entity.TB_APP_PROINFO model)
        {
            bool flag = false;
            int num = 0;
            if (model != null && model.AduRiskControl != null)
            {
                OracleConnection con = new OracleConnection(OracleHelper.connectionString);
                con.Open();
                OracleTransaction tran = con.BeginTransaction();
                OracleCommand cmd = con.CreateCommand();
                cmd.Transaction = tran;
                try
                {
                    //风控审批主体信息
                    long rptID = AddRISKCONTROL(ref cmd, model.AduRiskControl);

                    if (rptID > 0)
                    {
                        num++;
                        //风控审批客户综合认定信息
                        if (model.AduRiskControlCust != null && model.AduRiskControlCust.Count > 0)
                        {
                            if (AddRISKCONTROLCUST(ref cmd, model.AduRiskControlCust, rptID))
                                num++;
                        }
                        else
                            num++;


                        //风控审批项目综合认定信息
                        if (model.AduRiskControlPro != null && model.AduRiskControlPro.Count > 0)
                        {
                            if (AddRISKCONTROLPRO(ref cmd, model.AduRiskControlPro, rptID))
                                num++;
                        }
                        else
                            num++;

                    }
                    
                    
                      

                    if (num == 3)
                    {
                        tran.Commit();
                        flag = true;
                    }
                    else
                    {
                        tran.Rollback();

                    }

                }
                catch (Exception ex)
                {
                    log.ExceptionHand(ex);
                    tran.Rollback();
                }
                finally
                {
                    cmd.Dispose();
                    tran.Dispose();
                    con.Close();
                    con.Dispose();
                }

            }

            return flag;
        }

        /// <summary>
        ///  保存风控审批信息
        /// </summary>
        public long AddRISKCONTROL(ref OracleCommand cmd, GSLMS.Entity.TB_ADU_RISKCONTROL model)
        {


            long num = 0;

            OracleParameter[] parms = new OracleParameter[]{
								new OracleParameter("P_ID",OracleType.Number),
								new OracleParameter("P_PROID", model.PROID),
								new OracleParameter("P_AUDITBY", model.AUDITBY??""),
								new OracleParameter("P_AUDITTIME", model.AUDITTIME),
								new OracleParameter("P_STATUS", model.STATUS)};

            parms[0].Direction = ParameterDirection.Output;
            for (int i = 1; i < 5; i++)
            {
                parms[i].Direction = ParameterDirection.Input;
            }

            try
            {
                cmd.Parameters.Clear();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "pkg_audit.proc_riskcontrol_add";
                cmd.Parameters.AddRange(parms);
                cmd.ExecuteNonQuery();
                if (parms[0].Value != DBNull.Value)
                    num = OracleHelper.ToLong(parms[0].Value.ToString());
                
            }
            catch (Exception ex)
            {
                log.ExceptionHand(ex);
            }
            return num;
        }

        /// <summary>
        ///  新增风控审批客户综合认定信息
        /// </summary>
        public bool AddRISKCONTROLCUST(ref OracleCommand cmd, List<GSLMS.Entity.TB_ADU_RISKCONTROLCUST> list, long riskAuditID)
        {
            bool flag = false;
           
            if (list != null && list.Count > 0)
            {
                foreach (var model in list)
                {
                    OracleParameter[] parms = new OracleParameter[]{
								new OracleParameter("P_ID", model.ID),
								new OracleParameter("P_PROID", model.PROID),
								new OracleParameter("P_RISKCONID", riskAuditID),
								new OracleParameter("P_DATATYPE", model.DATATYPE??""),
								new OracleParameter("P_DATATYPENAME", model.DATATYPENAME??""),
								new OracleParameter("P_DATACONTENT", model.DATACONTENT??""),
								new OracleParameter("P_DATASORTNO", model.DATASORTNO)};

                    for (int i = 0; i < 7; i++)
                    {
                        parms[i].Direction = ParameterDirection.Input;
                    }

                    try
                    {
                        cmd.Parameters.Clear();
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.CommandText = "pkg_audit.proc_riskcontrolcust_add";
                        cmd.Parameters.AddRange(parms);
                        int num=cmd.ExecuteNonQuery();
                        if (num != 1)
                        {
                            return false;
                        }

                    }
                    catch (Exception ex)
                    {
                        log.ExceptionHand(ex);
                    }
                }
                flag = true;
            }
            else
                return true;

            return flag;
        }

        /// <summary>
        ///  新增风控审批项目综合认定信息
        /// </summary>
        public bool AddRISKCONTROLPRO(ref OracleCommand cmd, List<GSLMS.Entity.TB_ADU_RISKCONTROLPRO> list, long riskAuditID)
        {
            bool flag = false;
            if (list != null && list.Count > 0)
            {
                foreach (var model in list)
                {
                    OracleParameter[] parms = new OracleParameter[]{
								new OracleParameter("P_ID", model.ID),
								new OracleParameter("P_PROID", model.PROID),
								new OracleParameter("P_RISKCONID",riskAuditID),
								new OracleParameter("P_DATATYPE", model.DATATYPE??""),
								new OracleParameter("P_DATATYPENAME", model.DATATYPENAME??""),
								new OracleParameter("P_DATACONTENT", model.DATACONTENT??""),
								new OracleParameter("P_DATASORTNO", model.DATASORTNO)};

                    for (int i = 0; i < 7; i++)
                    {
                        parms[i].Direction = ParameterDirection.Input;
                    }


                    try
                    {
                        cmd.Parameters.Clear();
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.CommandText = "pkg_audit.proc_riskcontrolpro_add";
                        cmd.Parameters.AddRange(parms);
                        int num = cmd.ExecuteNonQuery();
                        if (num != 1)
                        {
                            return false;
                        }

                    }
                    catch (Exception ex)
                    {
                        log.ExceptionHand(ex);
                    }
                }
                flag = true;
            }
            else
                return true;

            return flag;
        }



		/// <summary>
		///  更新一条数据
		/// </summary>
		public override bool Update(GSLMS.Entity.TB_APP_PROINFO model)
		{
			bool flag = false;
            int num = 0;
			OracleParameter[] parms =new OracleParameter[]{
								new OracleParameter("P_ID", model.ID),
								new OracleParameter("P_REGINFOID", model.REGINFOID),
								new OracleParameter("P_CUSTNAME", model.CUSTNAME??""),
								new OracleParameter("P_DOCTYPE", model.DOCTYPE??""),
								new OracleParameter("P_DOCTYPENAME", model.DOCTYPENAME??""),
								new OracleParameter("P_CUSTNO", model.CUSTNO??""),
								new OracleParameter("P_APPLYNO", model.APPLYNO??""),
								new OracleParameter("P_APPDATE", model.APPDATE),
								new OracleParameter("P_LOANTYPE", model.LOANTYPE),
								new OracleParameter("P_SALESMANID", model.SALESMANID),
								new OracleParameter("P_SALESMAN", model.SALESMAN??""),
								new OracleParameter("P_DEPID", model.DEPID),
								new OracleParameter("P_DEPNAME", model.DEPNAME??""),
								new OracleParameter("P_BUSSTYPE", model.BUSSTYPE),
								new OracleParameter("P_PRODUCTID", model.PRODUCTID),
								new OracleParameter("P_PRODUCTNAME", model.PRODUCTNAME??""),
								new OracleParameter("P_MEDIATORID", model.MEDIATORID),
								new OracleParameter("P_MEDIATOR", model.MEDIATOR??""),
								new OracleParameter("P_MEDIATORACCOUNT", model.MEDIATORACCOUNT??""),
								new OracleParameter("P_MEDIATORTEL", model.MEDIATORTEL??""),
								new OracleParameter("P_SOURCE", model.SOURCE??""),
								new OracleParameter("P_ISSPECIAL", model.ISSPECIAL),
								new OracleParameter("P_SPECID", model.SPECID),
								new OracleParameter("P_CONTACT", model.CONTACT??""),
								new OracleParameter("P_CONTRACTTEL", model.CONTRACTTEL??""),
								new OracleParameter("P_CONTRACTTEL2", model.CONTRACTTEL2??""),
								new OracleParameter("P_AMOUNT", model.AMOUNT),
								new OracleParameter("P_LOANPHASE", model.LOANPHASE),
								new OracleParameter("P_LOANPHAESTYPE", model.LOANPHAESTYPE),
								new OracleParameter("P_RATE", model.RATE),
								new OracleParameter("P_MANAGEFEERATE", model.MANAGEFEERATE),
								new OracleParameter("P_GENERALRATE", model.GENERALRATE),
								new OracleParameter("P_LOANFEE", model.LOANFEE),
								new OracleParameter("P_STATUS", model.STATUS),
								new OracleParameter("P_CANCELBY", model.CANCELBY),
								new OracleParameter("P_CANCELDATE", model.CANCELDATE),
								new OracleParameter("P_CANCELREASON", model.CANCELREASON),
								new OracleParameter("P_BACKSTATUS", model.BACKSTATUS),
								new OracleParameter("P_BACKDATE", model.BACKDATE),
								new OracleParameter("P_BACKBY", model.BACKBY??""),
								new OracleParameter("P_BACKREASON", model.BACKREASON??""),
								new OracleParameter("P_FLOWSTATUS", model.FLOWSTATUS),
								new OracleParameter("P_SYSTEMID", model.SYSTEMID),
								new OracleParameter("P_SITENO", model.SITENO??""),
								new OracleParameter("P_SITENAME", model.SITENAME??""),
								new OracleParameter("P_SITEID", model.SITEID),
								new OracleParameter("P_SPAREFIELD1", model.SPAREFIELD1),
								new OracleParameter("P_SPAREFIELD2", model.SPAREFIELD2??""),
								new OracleParameter("P_SPAREFIELD3", model.SPAREFIELD3??""),
                                new OracleParameter("returnvalue",OracleType.Int32)
                };
  
			for (int i = 0; i < 49; i++)
			{
				parms[i].Direction = ParameterDirection.Input;
			}

            parms[49].Direction = ParameterDirection.Output;

            OracleConnection con = new OracleConnection(OracleHelper.connectionString);
            con.Open();
            OracleTransaction tran = con.BeginTransaction();
            OracleCommand cmd = con.CreateCommand();
            cmd.Transaction = tran;


            try
            {
                cmd.Parameters.Clear();
                cmd.Parameters.AddRange(parms);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "pkg_apply.proc_ProInfo_Update";
                //保存主表信息
                cmd.ExecuteNonQuery();
                long proID =model.ID;


                if (parms[49].Value != DBNull.Value && OracleHelper.ToInt(parms[49].Value.ToString()) == 1)
                {
                    //保存非赎楼信息
                    if (model.ProUnForHouInfo != null)
                    {
                        if (!AddProUnForHouInfo(ref cmd, model.ProUnForHouInfo, proID))
                            num++;
                    }
                    //保存股东信息
                    if (model.ProShareHolderInfos != null && model.ProShareHolderInfos.Count > 0)
                    {
                        if (!AddSharHolderInfo(ref cmd, model.ProShareHolderInfos, proID))
                            num++;
                    }

                    //保存赎楼信息
                    if (model.ProForHouInfo != null)
                    {
                        if (!AddProForHouInfo(ref cmd, model.ProForHouInfo, proID))
                            num++;
                    }

                    //保存风控审批信息
                    if (model.AduRiskControl != null)
                    {
                        long riskAduID = AddRISKCONTROL(ref cmd, model.AduRiskControl);
                      
                        if (riskAduID > 0)
                        {
                            if (model.AduRiskControlCust != null&&model.AduRiskControlCust.Count>0)
                            {
                                if (!AddRISKCONTROLCUST(ref cmd, model.AduRiskControlCust, riskAduID))
                                    num++;
                            }

                            if (model.AduRiskControlPro != null && model.AduRiskControlPro.Count > 0)
                            {
                                if (!AddRISKCONTROLPRO(ref cmd, model.AduRiskControlPro, riskAduID))
                                    num++;
                            }
                        }
                    }

                    if (num == 0)
                    {
                        tran.Commit();
                        flag = true;
                    }
                    else
                    {
                        tran.Rollback();
                    }
                }

            }
            catch (Exception ex)
            {
                log.ExceptionHand(ex);
                tran.Rollback();
            }
            finally
            {
                cmd.Dispose();
                tran.Dispose();
                con.Close();
                con.Dispose();
            }
			return flag;
		}

		/// <summary>
		///  删除一条数据
		/// </summary>
		public override bool Delete(long ID)
		{
			bool flag = false;
			OracleParameter[] parms =new OracleParameter[]{
								new OracleParameter("P_ID", ID),
                                new OracleParameter("returnvalue",OracleType.Int32)
               };
  
				parms[0].Direction = ParameterDirection.Input;
                parms[1].Direction = ParameterDirection.Output;

			try
			{
                OracleHelper.ExecuteNonQuery(OracleHelper.connectionString, CommandType.StoredProcedure, "pkg_apply.proc_ProInfo_Delete", parms);
                if(parms[1].Value!=DBNull.Value&&OracleHelper.ToInt(parms[1].Value.ToString())==1)
				 flag = true;
			}
			catch (Exception ex)
			{
				log.ExceptionHand(ex);
			}
			return flag;
		}

        

		/// <summary>
		///DataRowToModel 
		/// </summary>
		private GSLMS.Entity.TB_APP_PROINFO DataRowToModel(DataRow dr)
		{
			if (dr != null && dr.ItemArray.Length > 0)
			{
				GSLMS.Entity.TB_APP_PROINFO model = new GSLMS.Entity.TB_APP_PROINFO();
				if(dr["ID"]!=null && dr["ID"].ToString()!="")
				{
					model.ID=OracleHelper.ToLong(dr["ID"].ToString());
				}
				if(dr["REGINFOID"]!=null && dr["REGINFOID"].ToString()!="")
				{
					model.REGINFOID=OracleHelper.ToLong(dr["REGINFOID"].ToString());
				}
				if(dr["CUSTNAME"]!=null && dr["CUSTNAME"].ToString()!="")
				{
					model.CUSTNAME=dr["CUSTNAME"].ToString();
				}
				if(dr["DOCTYPE"]!=null && dr["DOCTYPE"].ToString()!="")
				{
					model.DOCTYPE=dr["DOCTYPE"].ToString();
				}
				if(dr["DOCTYPENAME"]!=null && dr["DOCTYPENAME"].ToString()!="")
				{
					model.DOCTYPENAME=dr["DOCTYPENAME"].ToString();
				}
				if(dr["CUSTNO"]!=null && dr["CUSTNO"].ToString()!="")
				{
					model.CUSTNO=dr["CUSTNO"].ToString();
				}
				if(dr["APPLYNO"]!=null && dr["APPLYNO"].ToString()!="")
				{
					model.APPLYNO=dr["APPLYNO"].ToString();
				}
				if(dr["APPDATE"]!=null && dr["APPDATE"].ToString()!="")
				{
					model.APPDATE=DateTime.Parse(dr["APPDATE"].ToString());
				}
				if(dr["LOANTYPE"]!=null && dr["LOANTYPE"].ToString()!="")
				{
                    model.LOANTYPE = OracleHelper.ToInt(dr["LOANTYPE"].ToString());
				}
				if(dr["SALESMANID"]!=null && dr["SALESMANID"].ToString()!="")
				{
					model.SALESMANID=OracleHelper.ToLong(dr["SALESMANID"].ToString());
				}
				if(dr["SALESMAN"]!=null && dr["SALESMAN"].ToString()!="")
				{
					model.SALESMAN=dr["SALESMAN"].ToString();
				}
				if(dr["DEPID"]!=null && dr["DEPID"].ToString()!="")
				{
					model.DEPID=OracleHelper.ToLong(dr["DEPID"].ToString());
				}
				if(dr["DEPNAME"]!=null && dr["DEPNAME"].ToString()!="")
				{
					model.DEPNAME=dr["DEPNAME"].ToString();
				}
				if(dr["BUSSTYPE"]!=null && dr["BUSSTYPE"].ToString()!="")
				{
                    model.BUSSTYPE = OracleHelper.ToInt(dr["BUSSTYPE"].ToString());
				}
				if(dr["PRODUCTID"]!=null && dr["PRODUCTID"].ToString()!="")
				{
					model.PRODUCTID=OracleHelper.ToLong(dr["PRODUCTID"].ToString());
				}
				if(dr["PRODUCTNAME"]!=null && dr["PRODUCTNAME"].ToString()!="")
				{
					model.PRODUCTNAME=dr["PRODUCTNAME"].ToString();
				}
				if(dr["MEDIATORID"]!=null && dr["MEDIATORID"].ToString()!="")
				{
					model.MEDIATORID=OracleHelper.ToLong(dr["MEDIATORID"].ToString());
				}
				if(dr["MEDIATOR"]!=null && dr["MEDIATOR"].ToString()!="")
				{
					model.MEDIATOR=dr["MEDIATOR"].ToString();
				}
				if(dr["MEDIATORACCOUNT"]!=null && dr["MEDIATORACCOUNT"].ToString()!="")
				{
					model.MEDIATORACCOUNT=dr["MEDIATORACCOUNT"].ToString();
				}
				if(dr["MEDIATORTEL"]!=null && dr["MEDIATORTEL"].ToString()!="")
				{
					model.MEDIATORTEL=dr["MEDIATORTEL"].ToString();
				}
				if(dr["SOURCE"]!=null && dr["SOURCE"].ToString()!="")
				{
					model.SOURCE=dr["SOURCE"].ToString();
				}
				if(dr["ISSPECIAL"]!=null && dr["ISSPECIAL"].ToString()!="")
				{
                    model.ISSPECIAL = OracleHelper.ToInt(dr["ISSPECIAL"].ToString());
				}
				if(dr["SPECID"]!=null && dr["SPECID"].ToString()!="")
				{
					model.SPECID=OracleHelper.ToLong(dr["SPECID"].ToString());
				}
				if(dr["CONTACT"]!=null && dr["CONTACT"].ToString()!="")
				{
					model.CONTACT=dr["CONTACT"].ToString();
				}
				if(dr["CONTRACTTEL"]!=null && dr["CONTRACTTEL"].ToString()!="")
				{
					model.CONTRACTTEL=dr["CONTRACTTEL"].ToString();
				}
				if(dr["CONTRACTTEL2"]!=null && dr["CONTRACTTEL2"].ToString()!="")
				{
					model.CONTRACTTEL2=dr["CONTRACTTEL2"].ToString();
				}
				if(dr["AMOUNT"]!=null && dr["AMOUNT"].ToString()!="")
				{
					model.AMOUNT=OracleHelper.ToDecimal(dr["AMOUNT"].ToString());
				}
				if(dr["LOANPHASE"]!=null && dr["LOANPHASE"].ToString()!="")
				{
                    model.LOANPHASE = OracleHelper.ToInt(dr["LOANPHASE"].ToString());
				}
				if(dr["LOANPHAESTYPE"]!=null && dr["LOANPHAESTYPE"].ToString()!="")
				{
                    model.LOANPHAESTYPE = OracleHelper.ToInt(dr["LOANPHAESTYPE"].ToString());
				}
				if(dr["RATE"]!=null && dr["RATE"].ToString()!="")
				{
					model.RATE=OracleHelper.ToDecimal(dr["RATE"].ToString());
				}
				if(dr["MANAGEFEERATE"]!=null && dr["MANAGEFEERATE"].ToString()!="")
				{
					model.MANAGEFEERATE=OracleHelper.ToDecimal(dr["MANAGEFEERATE"].ToString());
				}
				if(dr["GENERALRATE"]!=null && dr["GENERALRATE"].ToString()!="")
				{
					model.GENERALRATE=OracleHelper.ToDecimal(dr["GENERALRATE"].ToString());
				}
				if(dr["LOANFEE"]!=null && dr["LOANFEE"].ToString()!="")
				{
					model.LOANFEE=OracleHelper.ToDecimal(dr["LOANFEE"].ToString());
				}
				if(dr["STATUS"]!=null && dr["STATUS"].ToString()!="")
				{
                    model.STATUS = OracleHelper.ToInt(dr["STATUS"].ToString());
				}
				if(dr["CANCELBY"]!=null && dr["CANCELBY"].ToString()!="")
				{
					model.CANCELBY=dr["CANCELBY"].ToString();
				}
				if(dr["CANCELDATE"]!=null && dr["CANCELDATE"].ToString()!="")
				{
					model.CANCELDATE=DateTime.Parse(dr["CANCELDATE"].ToString());
				}
				if(dr["CANCELREASON"]!=null && dr["CANCELREASON"].ToString()!="")
				{
					model.CANCELREASON=dr["CANCELREASON"].ToString();
				}
				if(dr["BACKSTATUS"]!=null && dr["BACKSTATUS"].ToString()!="")
				{
					model.BACKSTATUS=OracleHelper.ToInt(dr["BACKSTATUS"].ToString());
				}
				if(dr["BACKDATE"]!=null && dr["BACKDATE"].ToString()!="")
				{
					model.BACKDATE=DateTime.Parse(dr["BACKDATE"].ToString());
				}
				if(dr["BACKBY"]!=null && dr["BACKBY"].ToString()!="")
				{
					model.BACKBY=dr["BACKBY"].ToString();
				}
				if(dr["BACKREASON"]!=null && dr["BACKREASON"].ToString()!="")
				{
					model.BACKREASON=dr["BACKREASON"].ToString();
				}
				if(dr["FLOWSTATUS"]!=null && dr["FLOWSTATUS"].ToString()!="")
				{
                    model.FLOWSTATUS = OracleHelper.ToInt(dr["FLOWSTATUS"].ToString());
				}
				if(dr["SYSTEMID"]!=null && dr["SYSTEMID"].ToString()!="")
				{
                    model.SYSTEMID = OracleHelper.ToInt(dr["SYSTEMID"].ToString());
				}
				if(dr["SITENO"]!=null && dr["SITENO"].ToString()!="")
				{
					model.SITENO=dr["SITENO"].ToString();
				}
				if(dr["SITENAME"]!=null && dr["SITENAME"].ToString()!="")
				{
					model.SITENAME=dr["SITENAME"].ToString();
				}
				if(dr["SITEID"]!=null && dr["SITEID"].ToString()!="")
				{
					model.SITEID=OracleHelper.ToLong(dr["SITEID"].ToString());
				}
				if(dr["SPAREFIELD1"]!=null && dr["SPAREFIELD1"].ToString()!="")
				{
                    model.SPAREFIELD1 = OracleHelper.ToInt(dr["SPAREFIELD1"].ToString());
				}
				if(dr["SPAREFIELD2"]!=null && dr["SPAREFIELD2"].ToString()!="")
				{
					model.SPAREFIELD2=dr["SPAREFIELD2"].ToString();
				}
				if(dr["SPAREFIELD3"]!=null && dr["SPAREFIELD3"].ToString()!="")
				{
					model.SPAREFIELD3=dr["SPAREFIELD3"].ToString();
				}
				return model;
			}
			else
			{
				return null;
			}
		}

        /// <summary>
        ///赎楼信息转成实体 
        /// </summary>
        private GSLMS.Entity.TB_APP_PROFORHOUINFO DataRowToModelProforHouInfo(DataRow dr)
        {
            if (dr != null && dr.ItemArray.Length > 0)
            {
                GSLMS.Entity.TB_APP_PROFORHOUINFO model = new GSLMS.Entity.TB_APP_PROFORHOUINFO();
                if (dr["ID"] != null && dr["ID"].ToString() != "")
                {
                    model.ID = OracleHelper.ToLong(dr["ID"].ToString());
                }
                if (dr["PROID"] != null && dr["PROID"].ToString() != "")
                {
                    model.PROID = OracleHelper.ToLong(dr["PROID"].ToString());
                }
                if (dr["REGINFOID"] != null && dr["REGINFOID"].ToString() != "")
                {
                    model.REGINFOID = OracleHelper.ToLong(dr["REGINFOID"].ToString());
                }
                if (dr["TRADEBY"] != null && dr["TRADEBY"].ToString() != "")
                {
                    model.TRADEBY = dr["TRADEBY"].ToString();
                }
                if (dr["FORHOUTYPE"] != null && dr["FORHOUTYPE"].ToString() != "")
                {
                    model.FORHOUTYPE = OracleHelper.ToInt(dr["FORHOUTYPE"].ToString());
                }
                if (dr["BUSSTYPE"] != null && dr["BUSSTYPE"].ToString() != "")
                {
                    model.BUSSTYPE = OracleHelper.ToInt(dr["BUSSTYPE"].ToString());
                }
                if (dr["HOUADD"] != null && dr["HOUADD"].ToString() != "")
                {
                    model.HOUADD = dr["HOUADD"].ToString();
                }
                if (dr["TENRIGHT"] != null && dr["TENRIGHT"].ToString() != "")
                {
                    model.TENRIGHT = dr["TENRIGHT"].ToString();
                }
                if (dr["TENBANK"] != null && dr["TENBANK"].ToString() != "")
                {
                    model.TENBANK = dr["TENBANK"].ToString();
                }
                if (dr["TENSUBBACK"] != null && dr["TENSUBBACK"].ToString() != "")
                {
                    model.TENSUBBACK = dr["TENSUBBACK"].ToString();
                }
                if (dr["TENENDDATE"] != null && dr["TENENDDATE"].ToString() != "")
                {
                    model.TENENDDATE = DateTime.Parse(dr["TENENDDATE"].ToString());
                }
                if (dr["TENLEFTAMT"] != null && dr["TENLEFTAMT"].ToString() != "")
                {
                    model.TENLEFTAMT = OracleHelper.ToDecimal(dr["TENLEFTAMT"].ToString());
                }
                if (dr["HOUPRICE"] != null && dr["HOUPRICE"].ToString() != "")
                {
                    model.HOUPRICE = OracleHelper.ToDecimal(dr["HOUPRICE"].ToString());
                }
                if (dr["HOUTOTALPRICE"] != null && dr["HOUTOTALPRICE"].ToString() != "")
                {
                    model.HOUTOTALPRICE = OracleHelper.ToDecimal(dr["HOUTOTALPRICE"].ToString());
                }
                if (dr["DOWNPAYAMT"] != null && dr["DOWNPAYAMT"].ToString() != "")
                {
                    model.DOWNPAYAMT = OracleHelper.ToDecimal(dr["DOWNPAYAMT"].ToString());
                }
                if (dr["FIRSTPAYAMT"] != null && dr["FIRSTPAYAMT"].ToString() != "")
                {
                    model.FIRSTPAYAMT = OracleHelper.ToDecimal(dr["FIRSTPAYAMT"].ToString());
                }
                if (dr["PAYMOD"] != null && dr["PAYMOD"].ToString() != "")
                {
                    model.PAYMOD = dr["PAYMOD"].ToString();
                }
                if (dr["PAYBANK"] != null && dr["PAYBANK"].ToString() != "")
                {
                    model.PAYBANK = dr["PAYBANK"].ToString();
                }
                if (dr["PAYSUBBANK"] != null && dr["PAYSUBBANK"].ToString() != "")
                {
                    model.PAYSUBBANK = dr["PAYSUBBANK"].ToString();
                }
                if (dr["PROMISEAMT"] != null && dr["PROMISEAMT"].ToString() != "")
                {
                    model.PROMISEAMT = OracleHelper.ToDecimal(dr["PROMISEAMT"].ToString());
                }
                if (dr["COUGUA1"] != null && dr["COUGUA1"].ToString() != "")
                {
                    model.COUGUA1 = dr["COUGUA1"].ToString();
                }
                if (dr["VERIFILD1"] != null && dr["VERIFILD1"].ToString() != "")
                {
                    model.VERIFILD1 = dr["VERIFILD1"].ToString();
                }
                if (dr["COUGUA2"] != null && dr["COUGUA2"].ToString() != "")
                {
                    model.COUGUA2 = dr["COUGUA2"].ToString();
                }
                if (dr["VERIFILD2"] != null && dr["VERIFILD2"].ToString() != "")
                {
                    model.VERIFILD2 = dr["VERIFILD2"].ToString();
                }
                if (dr["SIGNMAN"] != null && dr["SIGNMAN"].ToString() != "")
                {
                    model.SIGNMAN = dr["SIGNMAN"].ToString();
                }
                if (dr["SPAREFIELD1"] != null && dr["SPAREFIELD1"].ToString() != "")
                {
                    model.SPAREFIELD1 = OracleHelper.ToInt(dr["SPAREFIELD1"].ToString());
                }
                if (dr["SPAREFIELD2"] != null && dr["SPAREFIELD2"].ToString() != "")
                {
                    model.SPAREFIELD2 = dr["SPAREFIELD2"].ToString();
                }
                if (dr["SPAREFIELD3"] != null && dr["SPAREFIELD3"].ToString() != "")
                {
                    model.SPAREFIELD3 = dr["SPAREFIELD3"].ToString();
                }
                return model;
            }
            else
            {
                return null;
            }
        }

        /// <summary>
        ///非赎楼信息转成实体类 
        /// </summary>
        private GSLMS.Entity.TB_APP_PROUNFORHOUINFO DataRowToModelUnForHouInfo(DataRow dr)
        {
            if (dr != null && dr.ItemArray.Length > 0)
            {
                GSLMS.Entity.TB_APP_PROUNFORHOUINFO model = new GSLMS.Entity.TB_APP_PROUNFORHOUINFO();
                if (dr["ID"] != null && dr["ID"].ToString() != "")
                {
                    model.ID = OracleHelper.ToLong(dr["ID"].ToString());
                }
                if (dr["PROCID"] != null && dr["PROCID"].ToString() != "")
                {
                    model.PROCID = OracleHelper.ToLong(dr["PROCID"].ToString());
                }
                if (dr["REGINFOID"] != null && dr["REGINFOID"].ToString() != "")
                {
                    model.REGINFOID = OracleHelper.ToLong(dr["REGINFOID"].ToString());
                }
                if (dr["RISKBYID"] != null && dr["RISKBYID"].ToString() != "")
                {
                    model.RISKBYID = OracleHelper.ToLong(dr["RISKBYID"].ToString());
                }
                if (dr["RISKBYNAME"] != null && dr["RISKBYNAME"].ToString() != "")
                {
                    model.RISKBYNAME = dr["RISKBYNAME"].ToString();
                }
                if (dr["LEGAL"] != null && dr["LEGAL"].ToString() != "")
                {
                    model.LEGAL = dr["LEGAL"].ToString();
                }
                if (dr["LEGALTEL"] != null && dr["LEGALTEL"].ToString() != "")
                {
                    model.LEGALTEL = dr["LEGALTEL"].ToString();
                }
                if (dr["LEGALTEL2"] != null && dr["LEGALTEL2"].ToString() != "")
                {
                    model.LEGALTEL2 = dr["LEGALTEL2"].ToString();
                }
                if (dr["CONBY"] != null && dr["CONBY"].ToString() != "")
                {
                    model.CONBY = dr["CONBY"].ToString();
                }
                if (dr["CONBYTEL"] != null && dr["CONBYTEL"].ToString() != "")
                {
                    model.CONBYTEL = dr["CONBYTEL"].ToString();
                }
                if (dr["CONBYTEL2"] != null && dr["CONBYTEL2"].ToString() != "")
                {
                    model.CONBYTEL2 = dr["CONBYTEL2"].ToString();
                }
                if (dr["CORPADDRESS"] != null && dr["CORPADDRESS"].ToString() != "")
                {
                    model.CORPADDRESS = dr["CORPADDRESS"].ToString();
                }
                if (dr["REGAMOUNT"] != null && dr["REGAMOUNT"].ToString() != "")
                {
                    model.REGAMOUNT = OracleHelper.ToDecimal(dr["REGAMOUNT"].ToString());
                }
                if (dr["MAINBUSS"] != null && dr["MAINBUSS"].ToString() != "")
                {
                    model.MAINBUSS = dr["MAINBUSS"].ToString();
                }
                if (dr["REPAYMENT"] != null && dr["REPAYMENT"].ToString() != "")
                {
                    model.REPAYMENT = OracleHelper.ToInt(dr["REPAYMENT"].ToString());
                }
                if (dr["USEFOR"] != null && dr["USEFOR"].ToString() != "")
                {
                    model.USEFOR = dr["USEFOR"].ToString();
                }
                if (dr["ADVAMT"] != null && dr["ADVAMT"].ToString() != "")
                {
                    model.ADVAMT = OracleHelper.ToDecimal(dr["ADVAMT"].ToString());
                }
                if (dr["BUSSBRIEF"] != null && dr["BUSSBRIEF"].ToString() != "")
                {
                    model.BUSSBRIEF = dr["BUSSBRIEF"].ToString();
                }
                if (dr["LOANMODE"] != null && dr["LOANMODE"].ToString() != "")
                {
                    model.LOANMODE = dr["LOANMODE"].ToString();
                }
                if (dr["REPAYSOURCE"] != null && dr["REPAYSOURCE"].ToString() != "")
                {
                    model.REPAYSOURCE = dr["REPAYSOURCE"].ToString();
                }
                if (dr["SPAREFIELD1"] != null && dr["SPAREFIELD1"].ToString() != "")
                {
                    model.SPAREFIELD1 = OracleHelper.ToInt(dr["SPAREFIELD1"].ToString());
                }
                if (dr["SPAREFIELD2"] != null && dr["SPAREFIELD2"].ToString() != "")
                {
                    model.SPAREFIELD2 = dr["SPAREFIELD2"].ToString();
                }
                if (dr["SPAREFIELD3"] != null && dr["SPAREFIELD3"].ToString() != "")
                {
                    model.SPAREFIELD3 = dr["SPAREFIELD3"].ToString();
                }
                return model;
            }
            else
            {
                return null;
            }
        }


        /// <summary>
        ///股东信息转换成实体类 
        /// </summary>
        private GSLMS.Entity.TB_APP_SHAREHOLDERINFO DataRowToModelSharHoulderInfo(DataRow dr)
        {
            if (dr != null && dr.ItemArray.Length > 0)
            {
                GSLMS.Entity.TB_APP_SHAREHOLDERINFO model = new GSLMS.Entity.TB_APP_SHAREHOLDERINFO();
                if (dr["ID"] != null && dr["ID"].ToString() != "")
                {
                    model.ID = OracleHelper.ToLong(dr["ID"].ToString());
                }
                if (dr["REGINFOID"] != null && dr["REGINFOID"].ToString() != "")
                {
                    model.REGINFOID = OracleHelper.ToLong(dr["REGINFOID"].ToString());
                }
                if (dr["PROID"] != null && dr["PROID"].ToString() != "")
                {
                    model.PROID = OracleHelper.ToLong(dr["PROID"].ToString());
                }
                if (dr["NAME"] != null && dr["NAME"].ToString() != "")
                {
                    model.NAME = dr["NAME"].ToString();
                }
                if (dr["ADDRESS"] != null && dr["ADDRESS"].ToString() != "")
                {
                    model.ADDRESS = dr["ADDRESS"].ToString();
                }
                if (dr["TEL"] != null && dr["TEL"].ToString() != "")
                {
                    model.TEL = dr["TEL"].ToString();
                }
                if (dr["FUNDED"] != null && dr["FUNDED"].ToString() != "")
                {
                    model.FUNDED = dr["FUNDED"].ToString();
                }
                if (dr["AMOUNT"] != null && dr["AMOUNT"].ToString() != "")
                {
                    model.AMOUNT = OracleHelper.ToDecimal(dr["AMOUNT"].ToString());
                }
                if (dr["RATIO"] != null && dr["RATIO"].ToString() != "")
                {
                    model.RATIO = OracleHelper.ToDecimal(dr["RATIO"].ToString());
                }
                if (dr["ISPAYED"] != null && dr["ISPAYED"].ToString() != "")
                {
                    model.ISPAYED = OracleHelper.ToInt(dr["ISPAYED"].ToString());
                }
                if (dr["SPAREFIELD1"] != null && dr["SPAREFIELD1"].ToString() != "")
                {
                    model.SPAREFIELD1 = OracleHelper.ToInt(dr["SPAREFIELD1"].ToString());
                }
                if (dr["SPAREFIELD2"] != null && dr["SPAREFIELD2"].ToString() != "")
                {
                    model.SPAREFIELD2 = dr["SPAREFIELD2"].ToString();
                }
                if (dr["SPAREFIELD3"] != null && dr["SPAREFIELD3"].ToString() != "")
                {
                    model.SPAREFIELD3 = dr["SPAREFIELD3"].ToString();
                }
                return model;
            }
            else
            {
                return null;
            }
        }

        /// <summary>
        ///DataRowToModel转换成调查报告主体信息的实体 
        /// </summary>
        private GSLMS.Entity.TB_APP_PROREPORTINFO DataRowToModelReportInfo(DataRow dr)
        {
            if (dr != null && dr.ItemArray.Length > 0)
            {
                GSLMS.Entity.TB_APP_PROREPORTINFO model = new GSLMS.Entity.TB_APP_PROREPORTINFO();
                if (dr["ID"] != null && dr["ID"].ToString() != "")
                {
                    model.ID = OracleHelper.ToLong(dr["ID"].ToString());
                }
                if (dr["PROID"] != null && dr["PROID"].ToString() != "")
                {
                    model.PROID = OracleHelper.ToLong(dr["PROID"].ToString());
                }
                if (dr["REGINFOID"] != null && dr["REGINFOID"].ToString() != "")
                {
                    model.REGINFOID = OracleHelper.ToLong(dr["REGINFOID"].ToString());
                }
                if (dr["BUSSDETAIL"] != null && dr["BUSSDETAIL"].ToString() != "")
                {
                    model.BUSSDETAIL = dr["BUSSDETAIL"].ToString();
                }
                if (dr["REGDETAIL"] != null && dr["REGDETAIL"].ToString() != "")
                {
                    model.REGDETAIL = dr["REGDETAIL"].ToString();
                }
                if (dr["CORPNAME"] != null && dr["CORPNAME"].ToString() != "")
                {
                    model.CORPNAME = dr["CORPNAME"].ToString();
                }
                if (dr["CREATEDATE"] != null && dr["CREATEDATE"].ToString() != "")
                {
                    model.CREATEDATE = DateTime.Parse(dr["CREATEDATE"].ToString());
                }
                if (dr["REGCAPTAIL"] != null && dr["REGCAPTAIL"].ToString() != "")
                {
                    model.REGCAPTAIL = OracleHelper.ToDecimal(dr["REGCAPTAIL"].ToString());
                }
                if (dr["LEGALMAN"] != null && dr["LEGALMAN"].ToString() != "")
                {
                    model.LEGALMAN = dr["LEGALMAN"].ToString();
                }
                if (dr["BUSSTERM"] != null && dr["BUSSTERM"].ToString() != "")
                {
                    model.BUSSTERM = OracleHelper.ToDecimal(dr["BUSSTERM"].ToString());
                }
                if (dr["LOANNO"] != null && dr["LOANNO"].ToString() != "")
                {
                    model.LOANNO = dr["LOANNO"].ToString();
                }
                if (dr["CONBY"] != null && dr["CONBY"].ToString() != "")
                {
                    model.CONBY = dr["CONBY"].ToString();
                }
                if (dr["ANNCHECK"] != null && dr["ANNCHECK"].ToString() != "")
                {
                    model.ANNCHECK = dr["ANNCHECK"].ToString();
                }
                if (dr["REGADDR"] != null && dr["REGADDR"].ToString() != "")
                {
                    model.REGADDR = dr["REGADDR"].ToString();
                }
                if (dr["REGADDRTYPE"] != null && dr["REGADDRTYPE"].ToString() != "")
                {
                    model.REGADDRTYPE = dr["REGADDRTYPE"].ToString();
                }
                if (dr["REGTELCODE"] != null && dr["REGTELCODE"].ToString() != "")
                {
                    model.REGTELCODE = dr["REGTELCODE"].ToString();
                }
                if (dr["REGTEL"] != null && dr["REGTEL"].ToString() != "")
                {
                    model.REGTEL = dr["REGTEL"].ToString();
                }
                if (dr["REGTELSUB"] != null && dr["REGTELSUB"].ToString() != "")
                {
                    model.REGTELSUB = dr["REGTELSUB"].ToString();
                }
                if (dr["WORKADDR"] != null && dr["WORKADDR"].ToString() != "")
                {
                    model.WORKADDR = dr["WORKADDR"].ToString();
                }
                if (dr["WORKTELCODE"] != null && dr["WORKTELCODE"].ToString() != "")
                {
                    model.WORKTELCODE = dr["WORKTELCODE"].ToString();
                }
                if (dr["WORKTEL"] != null && dr["WORKTEL"].ToString() != "")
                {
                    model.WORKTEL = dr["WORKTEL"].ToString();
                }
                if (dr["WORKTELSUB"] != null && dr["WORKTELSUB"].ToString() != "")
                {
                    model.WORKTELSUB = dr["WORKTELSUB"].ToString();
                }
                if (dr["ISSPECAILCER"] != null && dr["ISSPECAILCER"].ToString() != "")
                {
                    model.ISSPECAILCER = OracleHelper.ToInt(dr["ISSPECAILCER"].ToString());
                }
                if (dr["HAVESPECAILCERS"] != null && dr["HAVESPECAILCERS"].ToString() != "")
                {
                    model.HAVESPECAILCERS = dr["HAVESPECAILCERS"].ToString();
                }
                if (dr["LEGALHOUADDR"] != null && dr["LEGALHOUADDR"].ToString() != "")
                {
                    model.LEGALHOUADDR = dr["LEGALHOUADDR"].ToString();
                }
                if (dr["LEGALADDR"] != null && dr["LEGALADDR"].ToString() != "")
                {
                    model.LEGALADDR = dr["LEGALADDR"].ToString();
                }
                if (dr["LEGALTEL"] != null && dr["LEGALTEL"].ToString() != "")
                {
                    model.LEGALTEL = dr["LEGALTEL"].ToString();
                }
                if (dr["LEGALTEL2"] != null && dr["LEGALTEL2"].ToString() != "")
                {
                    model.LEGALTEL2 = dr["LEGALTEL2"].ToString();
                }
                if (dr["CONBYADDR"] != null && dr["CONBYADDR"].ToString() != "")
                {
                    model.CONBYADDR = dr["CONBYADDR"].ToString();
                }
                if (dr["CONBYTEL"] != null && dr["CONBYTEL"].ToString() != "")
                {
                    model.CONBYTEL = dr["CONBYTEL"].ToString();
                }
                if (dr["CONBYTEL2"] != null && dr["CONBYTEL2"].ToString() != "")
                {
                    model.CONBYTEL2 = dr["CONBYTEL2"].ToString();
                }
                if (dr["OTHERREMARK"] != null && dr["OTHERREMARK"].ToString() != "")
                {
                    model.OTHERREMARK = dr["OTHERREMARK"].ToString();
                }
                if (dr["SURVEYBY"] != null && dr["SURVEYBY"].ToString() != "")
                {
                    model.SURVEYBY = dr["SURVEYBY"].ToString();
                }
                if (dr["SURVEYTIME"] != null && dr["SURVEYTIME"].ToString() != "")
                {
                    model.SURVEYTIME = DateTime.Parse(dr["SURVEYTIME"].ToString());
                }
                if (dr["STATUS"] != null && dr["STATUS"].ToString() != "")
                {
                    model.STATUS = OracleHelper.ToInt(dr["STATUS"].ToString());
                }
                if (dr["SPAREFIELD1"] != null && dr["SPAREFIELD1"].ToString() != "")
                {
                    model.SPAREFIELD1 = OracleHelper.ToInt(dr["SPAREFIELD1"].ToString());
                }
                if (dr["SPAREFIELD2"] != null && dr["SPAREFIELD2"].ToString() != "")
                {
                    model.SPAREFIELD2 = dr["SPAREFIELD2"].ToString();
                }
                if (dr["SPAREFIELD3"] != null && dr["SPAREFIELD3"].ToString() != "")
                {
                    model.SPAREFIELD3 = dr["SPAREFIELD3"].ToString();
                }
                return model;
            }
            else
            {
                return null;
            }
        }

        /// <summary>
        ///DataRowToModel 转成调查报告的股东实体
        /// </summary>
        private GSLMS.Entity.TB_APP_PROREPORTSHINFO DataRowToModelReportSHInfo(DataRow dr)
        {
            if (dr != null && dr.ItemArray.Length > 0)
            {
                GSLMS.Entity.TB_APP_PROREPORTSHINFO model = new GSLMS.Entity.TB_APP_PROREPORTSHINFO();
                if (dr["ID"] != null && dr["ID"].ToString() != "")
                {
                    model.ID = OracleHelper.ToLong(dr["ID"].ToString());
                }
                if (dr["REGINFOID"] != null && dr["REGINFOID"].ToString() != "")
                {
                    model.REGINFOID = OracleHelper.ToLong(dr["REGINFOID"].ToString());
                }
                if (dr["PROID"] != null && dr["PROID"].ToString() != "")
                {
                    model.PROID = OracleHelper.ToLong(dr["PROID"].ToString());
                }
                if (dr["REPORTID"] != null && dr["REPORTID"].ToString() != "")
                {
                    model.REPORTID = OracleHelper.ToLong(dr["REPORTID"].ToString());
                }
                if (dr["NAME"] != null && dr["NAME"].ToString() != "")
                {
                    model.NAME = dr["NAME"].ToString();
                }
                if (dr["ADDRESS"] != null && dr["ADDRESS"].ToString() != "")
                {
                    model.ADDRESS = dr["ADDRESS"].ToString();
                }
                if (dr["TEL"] != null && dr["TEL"].ToString() != "")
                {
                    model.TEL = dr["TEL"].ToString();
                }
                if (dr["FUNDED"] != null && dr["FUNDED"].ToString() != "")
                {
                    model.FUNDED = dr["FUNDED"].ToString();
                }
                if (dr["AMOUNT"] != null && dr["AMOUNT"].ToString() != "")
                {
                    model.AMOUNT = OracleHelper.ToDecimal(dr["AMOUNT"].ToString());
                }
                if (dr["RATIO"] != null && dr["RATIO"].ToString() != "")
                {
                    model.RATIO = OracleHelper.ToDecimal(dr["RATIO"].ToString());
                }
                if (dr["ISPAYED"] != null && dr["ISPAYED"].ToString() != "")
                {
                    model.ISPAYED = OracleHelper.ToInt(dr["ISPAYED"].ToString());
                }
                if (dr["SPAREFIELD1"] != null && dr["SPAREFIELD1"].ToString() != "")
                {
                    model.SPAREFIELD1 = OracleHelper.ToInt(dr["SPAREFIELD1"].ToString());
                }
                if (dr["SPAREFIELD2"] != null && dr["SPAREFIELD2"].ToString() != "")
                {
                    model.SPAREFIELD2 = dr["SPAREFIELD2"].ToString();
                }
                if (dr["SPAREFIELD3"] != null && dr["SPAREFIELD3"].ToString() != "")
                {
                    model.SPAREFIELD3 = dr["SPAREFIELD3"].ToString();
                }
                return model;
            }
            else
            {
                return null;
            }
        }

        /// <summary>
        ///DataRowToModel转成调查报告的调查对象实体 
        /// </summary>
        private GSLMS.Entity.TB_APP_PROCHECKOBJINFO DataRowToModelCheckObj(DataRow dr)
        {
            if (dr != null && dr.ItemArray.Length > 0)
            {
                GSLMS.Entity.TB_APP_PROCHECKOBJINFO model = new GSLMS.Entity.TB_APP_PROCHECKOBJINFO();
                if (dr["ID"] != null && dr["ID"].ToString() != "")
                {
                    model.ID = OracleHelper.ToLong(dr["ID"].ToString());
                }
                if (dr["REGINFOID"] != null && dr["REGINFOID"].ToString() != "")
                {
                    model.REGINFOID = OracleHelper.ToLong(dr["REGINFOID"].ToString());
                }
                if (dr["PROID"] != null && dr["PROID"].ToString() != "")
                {
                    model.PROID = OracleHelper.ToLong(dr["PROID"].ToString());
                }
                if (dr["REPORTID"] != null && dr["REPORTID"].ToString() != "")
                {
                    model.REPORTID = OracleHelper.ToLong(dr["REPORTID"].ToString());
                }
                if (dr["SURVEYOBJ"] != null && dr["SURVEYOBJ"].ToString() != "")
                {
                    model.SURVEYOBJ = dr["SURVEYOBJ"].ToString();
                }
                if (dr["SURVEYTIME"] != null && dr["SURVEYTIME"].ToString() != "")
                {
                    model.SURVEYTIME = DateTime.Parse(dr["SURVEYTIME"].ToString());
                }
                if (dr["OWNERSURVEYBY"] != null && dr["OWNERSURVEYBY"].ToString() != "")
                {
                    model.OWNERSURVEYBY = dr["OWNERSURVEYBY"].ToString();
                }
                if (dr["COUNTBY"] != null && dr["COUNTBY"].ToString() != "")
                {
                    model.COUNTBY = dr["COUNTBY"].ToString();
                }
                if (dr["COUNTBYIND"] != null && dr["COUNTBYIND"].ToString() != "")
                {
                    model.COUNTBYIND = dr["COUNTBYIND"].ToString();
                }
                if (dr["SPAREFIELD1"] != null && dr["SPAREFIELD1"].ToString() != "")
                {
                    model.SPAREFIELD1 = OracleHelper.ToInt(dr["SPAREFIELD1"].ToString());
                }
                if (dr["SPAREFIELD2"] != null && dr["SPAREFIELD2"].ToString() != "")
                {
                    model.SPAREFIELD2 = dr["SPAREFIELD2"].ToString();
                }
                if (dr["SPAREFIELD3"] != null && dr["SPAREFIELD3"].ToString() != "")
                {
                    model.SPAREFIELD3 = dr["SPAREFIELD3"].ToString();
                }
                return model;
            }
            else
            {
                return null;
            }
        }

        /// <summary>
		///DataRowToModel转成调查报告的调查项实体 
		/// </summary>
        private GSLMS.Entity.TB_APP_PROCHECKINFO DataRowToModelCheckInfo(DataRow dr)
        {
            if (dr != null && dr.ItemArray.Length > 0)
            {
                GSLMS.Entity.TB_APP_PROCHECKINFO model = new GSLMS.Entity.TB_APP_PROCHECKINFO();
                if (dr["ID"] != null && dr["ID"].ToString() != "")
                {
                    model.ID = OracleHelper.ToLong(dr["ID"].ToString());
                }
                if (dr["REGINFOID"] != null && dr["REGINFOID"].ToString() != "")
                {
                    model.REGINFOID = OracleHelper.ToLong(dr["REGINFOID"].ToString());
                }
                if (dr["PROID"] != null && dr["PROID"].ToString() != "")
                {
                    model.PROID = OracleHelper.ToLong(dr["PROID"].ToString());
                }
                if (dr["REPORTID"] != null && dr["REPORTID"].ToString() != "")
                {
                    model.REPORTID = OracleHelper.ToLong(dr["REPORTID"].ToString());
                }
                if (dr["PROCODE"] != null && dr["PROCODE"].ToString() != "")
                {
                    model.PROCODE = dr["PROCODE"].ToString();
                }
                if (dr["PRONAME"] != null && dr["PRONAME"].ToString() != "")
                {
                    model.PRONAME = dr["PRONAME"].ToString();
                }
                if (dr["SURCONTEN"] != null && dr["SURCONTEN"].ToString() != "")
                {
                    model.SURCONTEN = dr["SURCONTEN"].ToString();
                }
                if (dr["SORTNO"] != null && dr["SORTNO"].ToString() != "")
                {
                    model.SORTNO = OracleHelper.ToInt(dr["SORTNO"].ToString());
                }
                if (dr["SPAREFIELD1"] != null && dr["SPAREFIELD1"].ToString() != "")
                {
                    model.SPAREFIELD1 = OracleHelper.ToInt(dr["SPAREFIELD1"].ToString());
                }
                if (dr["SPAREFIELD2"] != null && dr["SPAREFIELD2"].ToString() != "")
                {
                    model.SPAREFIELD2 = dr["SPAREFIELD2"].ToString();
                }
                if (dr["SPAREFIELD3"] != null && dr["SPAREFIELD3"].ToString() != "")
                {
                    model.SPAREFIELD3 = dr["SPAREFIELD3"].ToString();
                }
                return model;
            }
            else
            {
                return null;
            }
        }

        /// <summary>
        ///DataRowToModel转成风控审批的实体 
        /// </summary>
        private GSLMS.Entity.TB_ADU_RISKCONTROL DataRowToModelRiskControl(DataRow dr)
        {
            if (dr != null && dr.ItemArray.Length > 0)
            {
                GSLMS.Entity.TB_ADU_RISKCONTROL model = new GSLMS.Entity.TB_ADU_RISKCONTROL();
                if (dr["ID"] != null && dr["ID"].ToString() != "")
                {
                    model.ID = OracleHelper.ToLong(dr["ID"].ToString());
                }
                if (dr["PROID"] != null && dr["PROID"].ToString() != "")
                {
                    model.PROID = OracleHelper.ToLong(dr["PROID"].ToString());
                }
                if (dr["AUDITBY"] != null && dr["AUDITBY"].ToString() != "")
                {
                    model.AUDITBY = dr["AUDITBY"].ToString();
                }
                if (dr["AUDITTIME"] != null && dr["AUDITTIME"].ToString() != "")
                {
                    model.AUDITTIME = DateTime.Parse(dr["AUDITTIME"].ToString());
                }
                if (dr["STATUS"] != null && dr["STATUS"].ToString() != "")
                {
                    model.STATUS = OracleHelper.ToInt(dr["STATUS"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }

        /// <summary>
        ///DataRowToModel转换成风控审批客户综合认定信息的实体 
        /// </summary>
        private GSLMS.Entity.TB_ADU_RISKCONTROLCUST DataRowToModelRiskControlCust(DataRow dr)
        {
            if (dr != null && dr.ItemArray.Length > 0)
            {
                GSLMS.Entity.TB_ADU_RISKCONTROLCUST model = new GSLMS.Entity.TB_ADU_RISKCONTROLCUST();
                if (dr["ID"] != null && dr["ID"].ToString() != "")
                {
                    model.ID = OracleHelper.ToLong(dr["ID"].ToString());
                }
                if (dr["PROID"] != null && dr["PROID"].ToString() != "")
                {
                    model.PROID = OracleHelper.ToLong(dr["PROID"].ToString());
                }
                if (dr["RISKCONID"] != null && dr["RISKCONID"].ToString() != "")
                {
                    model.RISKCONID = OracleHelper.ToLong(dr["RISKCONID"].ToString());
                }
                if (dr["DATATYPE"] != null && dr["DATATYPE"].ToString() != "")
                {
                    model.DATATYPE = dr["DATATYPE"].ToString();
                }
                if (dr["DATATYPENAME"] != null && dr["DATATYPENAME"].ToString() != "")
                {
                    model.DATATYPENAME = dr["DATATYPENAME"].ToString();
                }
                if (dr["DATACONTENT"] != null && dr["DATACONTENT"].ToString() != "")
                {
                    model.DATACONTENT = dr["DATACONTENT"].ToString();
                }
                if (dr["DATASORTNO"] != null && dr["DATASORTNO"].ToString() != "")
                {
                    model.DATASORTNO = OracleHelper.ToInt(dr["DATASORTNO"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }

        /// <summary>
        ///DataRowToModel 转换成风控审批项目综合认定信息的实体 
        /// </summary>
        private GSLMS.Entity.TB_ADU_RISKCONTROLPRO DataRowToModelRiskControlPro(DataRow dr)
        {
            if (dr != null && dr.ItemArray.Length > 0)
            {
                GSLMS.Entity.TB_ADU_RISKCONTROLPRO model = new GSLMS.Entity.TB_ADU_RISKCONTROLPRO();
                if (dr["ID"] != null && dr["ID"].ToString() != "")
                {
                    model.ID = OracleHelper.ToLong(dr["ID"].ToString());
                }
                if (dr["PROID"] != null && dr["PROID"].ToString() != "")
                {
                    model.PROID = OracleHelper.ToLong(dr["PROID"].ToString());
                }
                if (dr["RISKCONID"] != null && dr["RISKCONID"].ToString() != "")
                {
                    model.RISKCONID = OracleHelper.ToLong(dr["RISKCONID"].ToString());
                }
                if (dr["DATATYPE"] != null && dr["DATATYPE"].ToString() != "")
                {
                    model.DATATYPE = dr["DATATYPE"].ToString();
                }
                if (dr["DATATYPENAME"] != null && dr["DATATYPENAME"].ToString() != "")
                {
                    model.DATATYPENAME = dr["DATATYPENAME"].ToString();
                }
                if (dr["DATACONTENT"] != null && dr["DATACONTENT"].ToString() != "")
                {
                    model.DATACONTENT = dr["DATACONTENT"].ToString();
                }
                if (dr["DATASORTNO"] != null && dr["DATASORTNO"].ToString() != "")
                {
                    model.DATASORTNO = OracleHelper.ToInt(dr["DATASORTNO"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public override GSLMS.Entity.TB_APP_PROINFO GetByID(long ID)
		{
			GSLMS.Entity.TB_APP_PROINFO sModel = new GSLMS.Entity.TB_APP_PROINFO();
            OracleParameter[] parms = new OracleParameter[] { 
              new OracleParameter("p_id",ID),
              new OracleParameter("p_cur",OracleType.Cursor),
              new OracleParameter("p_houcur",OracleType.Cursor),
              new OracleParameter("p_unhoucur",OracleType.Cursor),
              new OracleParameter("p_shcur",OracleType.Cursor)
            };

            parms[0].Direction = ParameterDirection.Input;
            parms[1].Direction = ParameterDirection.Output;
            parms[2].Direction = ParameterDirection.Output;
            parms[3].Direction = ParameterDirection.Output;
            parms[4].Direction = ParameterDirection.Output;


           DataSet ds = OracleHelper.ExecuteDataset(OracleHelper.connectionString, CommandType.StoredProcedure, "pkg_apply.proc_proinfo_get", parms);
     
			if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
			{
				sModel = DataRowToModel(ds.Tables[0].Rows[0]);

                //赎楼信息
                if (ds.Tables.Count > 1 && ds.Tables[1].Rows.Count > 0)
                    sModel.ProForHouInfo = DataRowToModelProforHouInfo(ds.Tables[1].Rows[0]);

                //非赎楼信息
                if (ds.Tables.Count > 2 && ds.Tables[2].Rows.Count > 0)
                    sModel.ProUnForHouInfo = DataRowToModelUnForHouInfo(ds.Tables[2].Rows[0]);

                //股东信息
                if (ds.Tables.Count > 3 && ds.Tables[3].Rows.Count > 0)
                {
                    var shareHolderList = new List<GSLMS.Entity.TB_APP_SHAREHOLDERINFO>();
                    for (int i = 0; i < ds.Tables[3].Rows.Count; i++)
                    { 
                      shareHolderList.Add(DataRowToModelSharHoulderInfo(ds.Tables[3].Rows[i]));
                    }
                    sModel.ProShareHolderInfos = shareHolderList;
                }
			}
			else
			{
			return null;
			}
			return sModel;
		}

		/// <summary>
		/// 分页提取数据
		/// </summary>
		public override List<GSLMS.Entity.TB_APP_PROINFO> GetList(GSLMS.Entity.TB_APP_PROINFO searchParam)
		{
			var list=new List<GSLMS.Entity.TB_APP_PROINFO>();
			DataTable dt = null;
			string tblName = "TB_APP_PROINFO";
			string sqlWhere="";
			string strSort="";
			int pageSize=20;
			int pageIndex=1;
			string strFields="*";
			int totalCount = 0;
			int countFlag = 1;

            //是否计算总数
            countFlag = (searchParam.Pagination.ReCount != null && searchParam.Pagination.ReCount) ? 1 : 0;
            pageSize = (searchParam.Pagination.PageSize != null && searchParam.Pagination.PageSize > 0) ? searchParam.Pagination.PageSize : 15;
            pageIndex = (searchParam.Pagination.CurrentIndex != null && searchParam.Pagination.CurrentIndex > 0) ? searchParam.Pagination.CurrentIndex : 1;
            strSort = searchParam.StrSort;

           
            //客户名称：
            if (searchParam.CUSTNAME != null && searchParam.CUSTNAME.Trim() != "")
            {
                sqlWhere += " and custname like '%" + OracleHelper.ReplaceUnsafeSql(searchParam.CUSTNAME) + "%'";
            }
         
           
            //手机：
            if (searchParam.CONTRACTTEL != null && searchParam.CONTRACTTEL.Trim() != "")
            {
                sqlWhere += " and (CONTRACTTEL like '%" + OracleHelper.ReplaceUnsafeSql(searchParam.CONTRACTTEL) + "%' or CONTRACTTEL2 likie '%" + OracleHelper.ReplaceUnsafeSql(searchParam.CONTRACTTEL2) + "%'";
            }

            //处理状态:

            //状态:
            if (searchParam.STATUS>-1)
            {
                
                sqlWhere += " and status="+searchParam.STATUS.ToString();
            }
           


            //申请日期：
            if (searchParam.APPDATE != null && searchParam.APPDATE.ToString().Trim() != "")
            {
                sqlWhere += " and appdate>=to_date('" + Convert.ToDateTime(searchParam.APPDATE).ToString("yyyy-MM-dd HH:mm:ss") + "','yyyy-mm-dd hh24:mi:ss')";
            }

            if (searchParam.APPDATE_END != null && searchParam.APPDATE_END.ToString().Trim() != "")
            {
                sqlWhere += " and appdate<to_date('" + Convert.ToDateTime(searchParam.APPDATE_END).AddDays(1).AddSeconds(-1).ToString("yyyy-MM-dd HH:mm:ss") + "','yyyy-mm-dd hh24:mi:ss')";
            }
        
            //产品:
            if (searchParam.PRODUCTID>0)
            {
                sqlWhere += " and productid=" + searchParam.PRODUCTID.ToString();
            }
          
            //来源渠道:
            if (searchParam.SOURCE!=null&&searchParam.SOURCE!="")
            {
                sqlWhere += " and source='" + searchParam.SOURCE.Trim() + "'";
            }

            
            

            

			dt = OracleHelper.GetPageData(tblName, strFields, strSort, pageSize, pageIndex,countFlag, sqlWhere, out totalCount);

            if (searchParam.Pagination.ReCount)
            {
                searchParam.RowCount = totalCount;
                searchParam.Pagination.RowCount = totalCount;
            }

			if (dt != null && dt.Rows.Count > 0)
			{
				for (int i = 0; i < dt.Rows.Count; i++)
				{
					GSLMS.Entity.TB_APP_PROINFO model = new GSLMS.Entity.TB_APP_PROINFO();
					model = DataRowToModel(dt.Rows[i]);
					list.Add(model);
				}
			}
			else
			{
				return null;
			}
			return list;
		}

        /// <summary>
        /// 分页提取风控分配数据
        /// </summary>
        public List<GSLMS.Entity.TB_APP_PROINFO> GetAduAssignList(GSLMS.Entity.TB_APP_PROINFO searchParam)
        {
            var list = new List<GSLMS.Entity.TB_APP_PROINFO>();
            DataTable dt = null;
            string tblName = "V_ADU_ASSIGN";
            string sqlWhere = "";
            string strSort = "";
            int pageSize = 15;
            int pageIndex = 1;
            string strFields = "*";
            int totalCount = 0;
            int countFlag = 1;
            int dealingStatus = -1;

            countFlag = (searchParam.Pagination.ReCount != null && searchParam.Pagination.ReCount) ? 1 : 0;
            pageSize = (searchParam.Pagination.PageSize != null && searchParam.Pagination.PageSize > 0) ? searchParam.Pagination.PageSize : 15;
            pageIndex = (searchParam.Pagination.CurrentIndex != null && searchParam.Pagination.CurrentIndex > 0) ? searchParam.Pagination.CurrentIndex : 1;


            //客户名称：
            if (searchParam.CUSTNAME != null && searchParam.CUSTNAME.Trim() != "")
            {
                sqlWhere += " and custname like '%" + OracleHelper.ReplaceUnsafeSql(searchParam.CUSTNAME.Trim()) + "%'";
            }


            ////手机：
            //if (searchParam.CONTRACTTEL != null && searchParam.CONTRACTTEL.Trim() != "")
            //{
            //    sqlWhere += " and (CONTRACTTEL like '%" + OracleHelper.ReplaceUnsafeSql(searchParam.CONTRACTTEL) + "%' or CONTRACTTEL2 likie '%" + OracleHelper.ReplaceUnsafeSql(searchParam.CONTRACTTEL2) + "%'";
            //}

            ////处理状态:

            ////状态:
            //if (searchParam.STATUS > -1)
            //{

            //    sqlWhere += " and status=" + searchParam.STATUS.ToString();
            //}



            ////申请日期：
            //if (searchParam.APPDATE != null && searchParam.APPDATE.ToString().Trim() != "")
            //{
            //    sqlWhere += " and appdate>=to_date('" + Convert.ToDateTime(searchParam.APPDATE).ToString("yyyy-MM-dd HH:mm:ss") + "','yyyy-mm-dd hh24:mi:ss')";
            //}

            //if (searchParam.APPDATE_END != null && searchParam.APPDATE_END.ToString().Trim() != "")
            //{
            //    sqlWhere += " and appdate<to_date('" + Convert.ToDateTime(searchParam.APPDATE_END).AddDays(1).AddSeconds(-1).ToString("yyyy-MM-dd HH:mm:ss") + "','yyyy-mm-dd hh24:mi:ss')";
            //}

            //部门:
            if (searchParam.DEPID > 0)
            {
                sqlWhere += " and DEPID=" + searchParam.DEPID.ToString();
            }

            //产品:
            if (searchParam.PRODUCTID > 0)
            {
                sqlWhere += " and productid=" + searchParam.PRODUCTID.ToString();
            }

            //来源渠道:
            if (searchParam.SOURCE != null && searchParam.SOURCE != "")
            {
                sqlWhere += " and source='" + searchParam.SOURCE.Trim() + "'";
            }

            //系统记录ID:
            if (searchParam.SYSTEMID > 0)
            {
                sqlWhere += " and SYSTEMID=" + searchParam.SYSTEMID.ToString();
            }

            //使用作分配状态:
            if ((searchParam.RiskDealingStatus == 1 && searchParam.RiskDealingStatus2 == 1) || (searchParam.RiskDealingStatus == 0 && searchParam.RiskDealingStatus2 == 0))
                dealingStatus = -1;
            else if (searchParam.RiskDealingStatus == 1)
                dealingStatus = 0;
            else if (searchParam.RiskDealingStatus2 == 1)
                dealingStatus = 1;
            if(dealingStatus>-1)
                sqlWhere += " and dealingstatus=" + dealingStatus.ToString();




            dt = OracleHelper.GetPageData(tblName, strFields, strSort, pageSize, pageIndex, countFlag, sqlWhere, out totalCount);

            if (searchParam.Pagination.ReCount)
            {
                searchParam.RowCount = totalCount;
                searchParam.Pagination.RowCount = totalCount;
            }

            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    GSLMS.Entity.TB_APP_PROINFO model = new GSLMS.Entity.TB_APP_PROINFO();
                    model = DataRowToModel(dt.Rows[i]);
                    //风控分配信息
                    GSLMS.Entity.TB_ADU_ASSIGN assModel = new GSLMS.Entity.TB_ADU_ASSIGN();
                    assModel.ID = 0;
                    assModel.PROID = model.ID;
                    if (dt.Rows[i]["ASSIGNBY"] != null && dt.Rows[i]["ASSIGNBY"].ToString().Trim() != "")
                        assModel.ASSIGNBY = dt.Rows[i]["ASSIGNBY"].ToString().Trim();

                    if (dt.Rows[i]["ASSIGNBY"] != null && dt.Rows[i]["ASSIGNBY"].ToString().Trim() != "")
                        assModel.ASSIGNBY = dt.Rows[i]["ASSIGNBY"].ToString().Trim();

                    if (dt.Rows[i]["FLOWUSER"] != null && dt.Rows[i]["FLOWUSER"].ToString().Trim() != "")
                        assModel.FLOWUSER = dt.Rows[i]["FLOWUSER"].ToString().Trim();

                    if (dt.Rows[i]["ASSIGNTIME"] != null && dt.Rows[i]["ASSIGNTIME"].ToString().Trim() != "")
                        assModel.ASSIGNTIME = Convert.ToDateTime(dt.Rows[i]["ASSIGNTIME"].ToString().Trim());

                    if (dt.Rows[i]["dealingstatus"] != null && dt.Rows[i]["dealingstatus"].ToString().Trim() != "")
                        model.RiskDealingStatus = OracleHelper.ToInt(dt.Rows[i]["dealingstatus"].ToString().Trim());

                    

                    model.AduAssign = assModel;
                    list.Add(model);
                }
            }
            
            return list;
        }

        /// <summary>
        /// 分页提取风控审批数据
        /// </summary>
        public List<GSLMS.Entity.TB_APP_PROINFO> GetAduRiskList(GSLMS.Entity.TB_APP_PROINFO searchParam)
        {
            var list = new List<GSLMS.Entity.TB_APP_PROINFO>();
            DataTable dt = null;
            string tblName = "V_ADU_RISKCONTROL";
            string sqlWhere = "";
            string strSort = "";
            int pageSize = 15;
            int pageIndex = 1;
            string strFields = "*";
            int totalCount = 0;
            int countFlag = 1;
            int riskAuditStatus = -1;

            countFlag = (searchParam.Pagination.ReCount != null && searchParam.Pagination.ReCount) ? 1 : 0;
            pageSize = (searchParam.Pagination.PageSize != null && searchParam.Pagination.PageSize > 0) ? searchParam.Pagination.PageSize : 15;
            pageIndex = (searchParam.Pagination.CurrentIndex != null && searchParam.Pagination.CurrentIndex > 0) ? searchParam.Pagination.CurrentIndex : 1;


            //客户名称：
            if (searchParam.CUSTNAME != null && searchParam.CUSTNAME.Trim() != "")
            {
                sqlWhere += " and custname like '%" + OracleHelper.ReplaceUnsafeSql(searchParam.CUSTNAME.Trim()) + "%'";
            }



            //状态:
            if (searchParam.STATUS >0)
            {

                sqlWhere += " and status=" + searchParam.STATUS.ToString();
            }

            //部门:
            if (searchParam.DEPID > 0)
            {
                sqlWhere += " and DEPID=" + searchParam.DEPID.ToString();
            }

            //产品:
            if (searchParam.PRODUCTID > 0)
            {
                sqlWhere += " and productid=" + searchParam.PRODUCTID.ToString();
            }

            //来源渠道:
            if (searchParam.SOURCE != null && searchParam.SOURCE != "")
            {
                sqlWhere += " and source='" + searchParam.SOURCE.Trim() + "'";
            }

            //处理状态:
            if ((searchParam.RiskAuditStatus == 1 && searchParam.RiskAuditStatus2 == 1)||searchParam.RiskAuditStatus ==0 && searchParam.RiskAuditStatus2 ==0)
            {
                riskAuditStatus = -1;
            }
            else if (searchParam.RiskAuditStatus == 1)
            {
                riskAuditStatus =0;
            }
            else if (searchParam.RiskAuditStatus2 == 1)
            {
                riskAuditStatus =1;
            }

            if (riskAuditStatus > -1)
            {
                sqlWhere += " and riskauditstatus=" + riskAuditStatus.ToString();
            }
            





            dt = OracleHelper.GetPageData(tblName, strFields, strSort, pageSize, pageIndex, countFlag, sqlWhere, out totalCount);

            if (searchParam.Pagination.ReCount)
            {
                searchParam.RowCount = totalCount;
                searchParam.Pagination.RowCount = totalCount;
            }

            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    GSLMS.Entity.TB_APP_PROINFO model = new GSLMS.Entity.TB_APP_PROINFO();
                    model = DataRowToModel(dt.Rows[i]);
                    //风控分配信息
                    GSLMS.Entity.TB_ADU_ASSIGN assModel = new GSLMS.Entity.TB_ADU_ASSIGN();
                    assModel.ID = 0;
                    assModel.PROID = model.ID;
                    if (dt.Rows[i]["ASSIGNBY"] != null && dt.Rows[i]["ASSIGNBY"].ToString().Trim() != "")
                        assModel.ASSIGNBY = dt.Rows[i]["ASSIGNBY"].ToString().Trim();

                    if (dt.Rows[i]["ASSIGNBY"] != null && dt.Rows[i]["ASSIGNBY"].ToString().Trim() != "")
                        assModel.ASSIGNBY = dt.Rows[i]["ASSIGNBY"].ToString().Trim();

                    if (dt.Rows[i]["FLOWUSER"] != null && dt.Rows[i]["FLOWUSER"].ToString().Trim() != "")
                        assModel.FLOWUSER = dt.Rows[i]["FLOWUSER"].ToString().Trim();

                    if (dt.Rows[i]["ASSIGNTIME"] != null && dt.Rows[i]["ASSIGNTIME"].ToString().Trim() != "")
                        assModel.ASSIGNTIME = Convert.ToDateTime(dt.Rows[i]["ASSIGNTIME"].ToString().Trim());

                    if (dt.Rows[i]["dealingstatus"] != null && dt.Rows[i]["dealingstatus"].ToString().Trim() != "")
                        model.RiskDealingStatus = OracleHelper.ToInt(dt.Rows[i]["dealingstatus"].ToString().Trim());

                    model.AduAssign = assModel;


                    //风控审批信息
                    GSLMS.Entity.TB_ADU_RISKCONTROL riskModel = new GSLMS.Entity.TB_ADU_RISKCONTROL();
                    
                   if (dt.Rows[i]["riskauditid"] != null && dt.Rows[i]["riskauditid"].ToString().Trim() != "")
                        riskModel.ID = OracleHelper.ToLong(dt.Rows[i]["riskauditid"].ToString().Trim());


                    riskModel.PROID = model.ID;

                    if (dt.Rows[i]["riskauditby"] != null && dt.Rows[i]["riskauditby"].ToString().Trim() != "")
                        riskModel.AUDITBY = dt.Rows[i]["riskauditby"].ToString().Trim();

                    if (dt.Rows[i]["riskaudittime"] != null && dt.Rows[i]["riskaudittime"].ToString().Trim() != "")
                        riskModel.AUDITTIME = Convert.ToDateTime(dt.Rows[i]["riskaudittime"].ToString().Trim());

                    if (dt.Rows[i]["riskauditstatus"] != null && dt.Rows[i]["riskauditstatus"].ToString().Trim() != "")
                    {
                        riskModel.STATUS = OracleHelper.ToInt(dt.Rows[i]["riskauditstatus"].ToString().Trim());
                        model.RiskAuditStatus = OracleHelper.ToInt(dt.Rows[i]["riskauditstatus"].ToString().Trim());
                    }
                    else
                        model.RiskAuditStatus = 0;


                    model.AduRiskControl = riskModel;
                    
                    list.Add(model);
                }
            }

            return list;
        }

        /// <summary>
        /// 提取非赎楼信息的风控调查报告信息
        /// </summary>
        /// <param name="proID">立项申请记录ID</param>
        /// <returns></returns>
        public GSLMS.Entity.TB_APP_PROINFO GetProRiskControlReportInfo(long proID)
        {
            GSLMS.Entity.TB_APP_PROINFO model = new GSLMS.Entity.TB_APP_PROINFO();

            OracleParameter[] parms = new OracleParameter[] { 
               new OracleParameter("p_proid",proID),
               new OracleParameter("p_cur",OracleType.Cursor),
               new OracleParameter("p_rcur",OracleType.Cursor),
               new OracleParameter("p_ufcur",OracleType.Cursor),
               new OracleParameter("p_ctcur",OracleType.Cursor),
               new OracleParameter("p_prcur",OracleType.Cursor)
            };

            parms[0].Direction = ParameterDirection.Input;
            parms[1].Direction = ParameterDirection.Output;
            parms[2].Direction = ParameterDirection.Output;
            parms[3].Direction = ParameterDirection.Output;
            parms[4].Direction = ParameterDirection.Output;
            parms[5].Direction = ParameterDirection.Output;

        //           --提取非赎楼的风控审批信息
        //procedure proc_riskcontrol_get(
        //  p_proid in number,
        //  p_cur out t_cursor,--立项申请信息
        //  p_rcur out t_cursor,--风控审批信息
        //  p_ufcur out t_cursor,--非赎楼信息
        //  p_ctcur out t_cursor,--客户综合认定信息
        //  p_prcur out t_cursor--项目综合认定信息
        //)

            DataSet ds = OracleHelper.ExecuteDataset(OracleHelper.connectionString, CommandType.StoredProcedure, "pkg_audit.proc_riskcontrol_get", parms);
            if (ds != null && ds.Tables.Count > 0)
            {
                //基本信息
                model = DataRowToModel(ds.Tables[0].Rows[0]);

                //风控审批信息
                var riskAuditControl = new GSLMS.Entity.TB_ADU_RISKCONTROL();
                if (ds.Tables.Count > 1 && ds.Tables[1].Rows.Count > 0)
                {
                    riskAuditControl =DataRowToModelRiskControl(ds.Tables[1].Rows[0]);
                }
                model.AduRiskControl = riskAuditControl;


                //非赎楼信息
                var unforHou = new Entity.TB_APP_PROUNFORHOUINFO();
                if (ds.Tables.Count > 2 && ds.Tables[2].Rows.Count > 0)
                {
                    unforHou = DataRowToModelUnForHouInfo(ds.Tables[2].Rows[0]);
                }
                model.ProUnForHouInfo = unforHou;

               

                //客户综合认定信息
                var riskControlCustList = new List<GSLMS.Entity.TB_ADU_RISKCONTROLCUST>();
                if (ds.Tables.Count > 3 && ds.Tables[3].Rows.Count > 0)
                {
                    for (int j = 0; j < ds.Tables[3].Rows.Count; j++)
                    {
                        riskControlCustList.Add(DataRowToModelRiskControlCust(ds.Tables[3].Rows[j]));
                    }
                }
                model.AduRiskControlCust = riskControlCustList;

                //项目综合认定信息
                var riskControlProList = new List<GSLMS.Entity.TB_ADU_RISKCONTROLPRO>();
                if (ds.Tables.Count > 4 && ds.Tables[4].Rows.Count > 0)
                {
                    for (int k = 0; k < ds.Tables[4].Rows.Count; k++)
                    {
                        riskControlProList.Add(DataRowToModelRiskControlPro(ds.Tables[4].Rows[k]));
                    }
                }
                model.AduRiskControlPro =riskControlProList;


            }



            return model;
        }

        /// <summary>
		/// 得到一个风控分配的实体
		/// </summary>
        public GSLMS.Entity.TB_APP_PROINFO GetAduAssignByID(long ID)
        {
            GSLMS.Entity.TB_APP_PROINFO model = new Entity.TB_APP_PROINFO();
            string sql = "";
            sql = "select * from V_ADU_ASSIGN where id="+ID.ToString();
            DataSet ds = OracleHelper.ExecuteDataset(sql);
            DataTable dt=null;
            if (ds != null && ds.Tables.Count > 0)
                dt = ds.Tables[0];
            if (dt != null && dt.Rows.Count > 0)
            {
                model = DataRowToModel(dt.Rows[0]);

                //风控分配信息
                GSLMS.Entity.TB_ADU_ASSIGN assModel = new GSLMS.Entity.TB_ADU_ASSIGN();
                assModel.ID = 0;
                assModel.PROID = model.ID;
                if (dt.Rows[0]["ASSIGNBY"] != null && dt.Rows[0]["ASSIGNBY"].ToString().Trim() != "")
                    assModel.ASSIGNBY = dt.Rows[0]["ASSIGNBY"].ToString().Trim();

                if (dt.Rows[0]["ASSIGNBY"] != null && dt.Rows[0]["ASSIGNBY"].ToString().Trim() != "")
                    assModel.ASSIGNBY = dt.Rows[0]["ASSIGNBY"].ToString().Trim();

                if (dt.Rows[0]["FLOWUSER"] != null && dt.Rows[0]["FLOWUSER"].ToString().Trim() != "")
                    assModel.FLOWUSER = dt.Rows[0]["FLOWUSER"].ToString().Trim();

                if (dt.Rows[0]["ASSIGNTIME"] != null && dt.Rows[0]["ASSIGNTIME"].ToString().Trim() != "")
                    assModel.ASSIGNTIME = Convert.ToDateTime(dt.Rows[0]["ASSIGNTIME"].ToString().Trim());

                if (dt.Rows[0]["dealingstatus"] != null && dt.Rows[0]["dealingstatus"].ToString().Trim() != "")
                    model.RiskDealingStatus = OracleHelper.ToInt(dt.Rows[0]["dealingstatus"].ToString().Trim());

                model.AduAssign = assModel;
            }
            else
                return null;

            return model;
        }

        /// <summary>
        ///通过申请记录ID，提取立项申请中共有的信息，用于转立项申请功能
        /// </summary>
        /// <param name="regInfoID">申请登记记录ID</param>
        /// <returns></returns>
        public  GSLMS.Entity.TB_APP_PROINFO GetByRegInfoID(long regInfoID)
        {
            GSLMS.Entity.TB_APP_PROINFO model = new Entity.TB_APP_PROINFO();
             GSLMS.Entity.TB_APP_REGINFO regModel = new Entity.TB_APP_REGINFO();
            APP_REGINFO regBll = new APP_REGINFO();

            regModel = regBll.GetByID(regInfoID);

            if (regModel != null)
            {
                model.ID = 0;
                //申请登记记录ID
                model.REGINFOID = regModel.ID;
                //客户名称	CustName
                model.CUSTNAME = regModel.CUSTNAME;
                //证件号码	CustNo	
                model.CUSTNO = regModel.CUSTNO;
                //来源渠道	Source
                model.SOURCE = regModel.SOURCE;
                //联系人	LinkMan
                model.CONTACT = regModel.LINKMAN;
                //联系人手机	LinkManTel
                model.CONTRACTTEL = regModel.LINKMANTEL;
                //业务员记录ID	SalesManID
                model.SALESMANID = regModel.SALESMANID;
                //业务员	SalesMan
                model.SALESMAN = regModel.SALESMAN;
                //中介人记录ID	MediatorID
                model.MEDIATORID = regModel.MEDIATORID;
                //中介人	Mediator
                model.MEDIATOR = regModel.MEDIATOR;
                //业务种类	BussType
                model.BUSSTYPE = regModel.BUSSTYPE;

                //贷款产品	ProductID
                model.PRODUCTID = regModel.PRODUCTID;
                //贷款产品名称	ProductName
                model.PRODUCTNAME = regModel.PRODUCTNAME;
                //贷款期限	LoanPhase
                model.LOANPHASE = regModel.LOANPHASE;
                //贷款期限类型	LoanPhaseType
                model.LOANPHAESTYPE = regModel.LOANPHASETYPE;
                //意向贷款金额	IntemtionAmt
                model.AMOUNT = regModel.INTEMTIONAMT;
                //所属部门记录ID	DepID
                model.DEPID = regModel.DEPID;
                //所属部门名称	DepName	
                model.DEPNAME = regModel.DEPNAME;

                if (model.BUSSTYPE == 2)
                {
                    GSLMS.Entity.TB_APP_PROFORHOUINFO proforHouInfo = new Entity.TB_APP_PROFORHOUINFO();
                    proforHouInfo.REGINFOID = regModel.ID;
                    proforHouInfo.SPAREFIELD1 = 1;
                    proforHouInfo.FORHOUTYPE = 0;
                    proforHouInfo.SIGNMAN = "";
                    model.ProForHouInfo = proforHouInfo;
                }
                else
                {
                    GSLMS.Entity.TB_APP_PROUNFORHOUINFO proUnForHouInfo = new Entity.TB_APP_PROUNFORHOUINFO();
                    proUnForHouInfo.REGINFOID = regModel.ID;
                    model.ProUnForHouInfo = proUnForHouInfo;
                }
            }

            return model;
        }

        /// <summary>
        /// 通过立项申请记录ID，提取提交页面所需的信息，用于提交页面
        /// </summary>
        /// <param name="proInfoID">立项申请记录ID</param>
        /// <returns></returns>
        public GSLMS.Entity.TB_APP_PROINFO GetSubmiShow(long proInfoID)
        {
            GSLMS.Entity.TB_APP_PROINFO model = new Entity.TB_APP_PROINFO();
            OracleParameter[] parms = new OracleParameter[] { 
               new OracleParameter("p_id",proInfoID),
               new OracleParameter("p_cur",OracleType.Cursor)
            };

            parms[0].Direction = ParameterDirection.Input;
            parms[1].Direction = ParameterDirection.Output;

            DataSet ds = OracleHelper.ExecuteDataset(OracleHelper.connectionString, CommandType.StoredProcedure, "pkg_apply.proc_proinfo_getsubmitshow", parms);
            if (ds != null && ds.Tables.Count > 0&&ds.Tables[0].Rows.Count>0)
            {
                model.TraInfoCount = OracleHelper.ToInt(ds.Tables[0].Rows[0]["tarcount"].ToString());
                model.ConInfoCount = OracleHelper.ToInt(ds.Tables[0].Rows[0]["concount"].ToString());
                model.FileInfoCount = OracleHelper.ToInt(ds.Tables[0].Rows[0]["anncount"].ToString());
            }

            return model;
        }

        /// <summary>
        /// 提交立项申请,实体中传入ID及submitby
        /// </summary>
        /// <param name="TB_APP_PROINFO"></param>
        /// <returns></returns>
        public bool SubmitPro(GSLMS.Entity.TB_APP_PROINFO model)
        {
            bool flag = false;
            int num=0;
            OracleParameter[] parms = new OracleParameter[] { 
               new OracleParameter("p_id",model.ID),
               new OracleParameter("p_submitby",model.SubmitBy),
               new OracleParameter("returnvalue",OracleType.Int32)
            };

            parms[0].Direction = ParameterDirection.Input;
            parms[1].Direction = ParameterDirection.Input;
            parms[2].Direction = ParameterDirection.Output;

            try
            {
                OracleHelper.ExecuteNonQuery(OracleHelper.connectionString, CommandType.StoredProcedure, "pkg_apply.proc_proinfo_submit", parms);
                if (parms[2].Value != DBNull.Value)
                    num = OracleHelper.ToInt(parms[2].Value.ToString());

                // --1成功,0失败,-1此立项申请的状态不是保存状态，不允许提交
                if (num == 1)
                    flag = true;
            }
            catch (Exception ex)
            {
                log.ExceptionHand(ex);
            }

            return flag;
        }

        /// <summary>
        /// 取消立项申请,实体中传入ID及cancelBy、cancelreason
        /// </summary>
        /// <param name="TB_APP_PROINFO"></param>
        /// <returns></returns>
        public bool CancelPro(GSLMS.Entity.TB_APP_PROINFO model)
        {
            bool flag = false;
            int num = 0;
            OracleParameter[] parms = new OracleParameter[] { 
               new OracleParameter("p_id",model.ID),
               new OracleParameter("p_cancelby",model.CANCELBY),
               new OracleParameter("p_cancelreason",model.CANCELREASON),
               new OracleParameter("returnvalue",OracleType.Int32)
            };

            parms[0].Direction = ParameterDirection.Input;
            parms[1].Direction = ParameterDirection.Input;
            parms[2].Direction = ParameterDirection.Input;
            parms[3].Direction = ParameterDirection.Output;


            try
            {
                OracleHelper.ExecuteNonQuery(OracleHelper.connectionString, CommandType.StoredProcedure, "pkg_apply.proc_proinfo_cancel", parms);
                if (parms[3].Value != DBNull.Value)
                    num = OracleHelper.ToInt(parms[3].Value.ToString());

                //--1成功,0失败,-1此立项申请的状态不是保存状态，不允许取消
                if (num == 1)
                    flag = true;
            }
            catch (Exception ex)
            {
                log.ExceptionHand(ex);
            }



            return flag;

            

        }

        /// <summary>
        /// 提取非赎楼信息的调查报告信息
        /// </summary>
        /// <param name="proID">立项申请记录ID</param>
        /// <returns></returns>
        public GSLMS.Entity.TB_APP_PROINFO GetProReportInfo(long proID)
        {
            GSLMS.Entity.TB_APP_PROINFO model = new GSLMS.Entity.TB_APP_PROINFO();

            OracleParameter[] parms = new OracleParameter[] { 
               new OracleParameter("P_PROID",proID),
               new OracleParameter("p_cur",OracleType.Cursor),
               new OracleParameter("p_rcur",OracleType.Cursor),
               new OracleParameter("p_scur",OracleType.Cursor),
               new OracleParameter("p_ocur",OracleType.Cursor),
               new OracleParameter("p_ccur",OracleType.Cursor)
            };

            parms[0].Direction = ParameterDirection.Input;
            parms[1].Direction = ParameterDirection.Output;
            parms[2].Direction = ParameterDirection.Output;
            parms[3].Direction = ParameterDirection.Output;
            parms[4].Direction = ParameterDirection.Output;
            parms[5].Direction = ParameterDirection.Output;

            //--提取调查报告信息
            //procedure proc_proreportinfo_get(
            //  in number,--立项申请记录ID
            //  out t_cursor,--立项申请基本信息
            // p_rcur out t_cursor,--调查报告主体信息
            // p_scur out t_cursor,--调查报告股东信息
            // p_ocur out t_cursor,--调查对象信息
            // p_ccur out t_cursor --调查项信息
            //)

            DataSet ds = OracleHelper.ExecuteDataset(OracleHelper.connectionString, CommandType.StoredProcedure, "pkg_apply.proc_proreportinfo_get", parms);
            if (ds != null && ds.Tables.Count > 0)
            {
                //基本信息
                model = DataRowToModel(ds.Tables[0].Rows[0]);
                GSLMS.Entity.TB_APP_PROUNFORHOUINFO unforHou = new Entity.TB_APP_PROUNFORHOUINFO();
                if (ds.Tables[0].Rows[0]["REPAYMENT"].ToString() != "0")
                {
                    unforHou.REPAYMENT = OracleHelper.ToInt(ds.Tables[0].Rows[0]["REPAYMENT"].ToString());
                }
                else
                {
                    unforHou.REPAYMENT = 0;
                }
                model.ProUnForHouInfo = unforHou;

                //调查报告主体信息
                var reportInfo = new GSLMS.Entity.TB_APP_PROREPORTINFO();
                if (ds.Tables.Count > 1&&ds.Tables[1].Rows.Count>0)
                {
                    reportInfo = DataRowToModelReportInfo(ds.Tables[1].Rows[0]);
                }
                model.ProReport = reportInfo;

                //调查报告股东信息
                var reportShInfo = new List<GSLMS.Entity.TB_APP_PROREPORTSHINFO>();
                if (ds.Tables.Count > 2 && ds.Tables[2].Rows.Count > 0)
                {
                    for (int i = 0; i < ds.Tables[2].Rows.Count; i++)
                    {
                        reportShInfo.Add(DataRowToModelReportSHInfo(ds.Tables[2].Rows[i]));
                    }
                }
                model.ProReportSHInfo = reportShInfo;

                //调查对象信息
                var ProCheckObjList = new List<GSLMS.Entity.TB_APP_PROCHECKOBJINFO>();
                if (ds.Tables.Count > 3 && ds.Tables[3].Rows.Count > 0)
                {
                    for (int j = 0; j < ds.Tables[3].Rows.Count; j++)
                    {
                        ProCheckObjList.Add(DataRowToModelCheckObj(ds.Tables[3].Rows[j]));
                    }
                }
                model.ProCheckObj = ProCheckObjList;

                //调查项信息
                var proCheckInfoList = new List<GSLMS.Entity.TB_APP_PROCHECKINFO>();
                if (ds.Tables.Count > 4 && ds.Tables[4].Rows.Count > 0)
                {
                    for (int k = 0; k < ds.Tables[4].Rows.Count; k++)
                    {
                        proCheckInfoList.Add(DataRowToModelCheckInfo(ds.Tables[4].Rows[k]));
                    }
                }
                model.ProCheckInfo = proCheckInfoList;


            }



            return model;
        }

        /// <summary>
        /// 新增调查报告信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool AddProReportInfo(GSLMS.Entity.TB_APP_PROINFO model)
        {
            bool flag = false;
            int num = 0;
            if (model != null && model.ProReport != null)
            {
                OracleConnection con = new OracleConnection(OracleHelper.connectionString);
                con.Open();
                OracleTransaction tran = con.BeginTransaction();
                OracleCommand cmd = con.CreateCommand();
                cmd.Transaction = tran;
                try
                {
                    //调查主体信息
                    long rptID = AddReport(ref cmd,model.ProReport);

                    if (rptID > 0)
                    {
                        num++;
                        //调查报告股东信息
                        if (model.ProReportSHInfo != null && model.ProReportSHInfo.Count > 0)
                        {
                            if (AddReportSHinfo(ref cmd, model.ProReportSHInfo, rptID, model.ProReport.PROID, model.ProReport.REGINFOID))
                                num++;
                        }
                        else
                            num++;

                        //调查报告调查对象信息
                        if (model.ProCheckObj != null && model.ProCheckObj.Count > 0)
                        {
                            if (AddCheckObjInfo(ref cmd, model.ProCheckObj, rptID, model.ProReport.PROID, model.ProReport.REGINFOID))
                                num++;
                        }
                        else
                            num++;

                        //调查报告调查项信息
                        if (model.ProCheckInfo != null && model.ProCheckInfo.Count > 0)
                        {
                            if (AddCheckInfo(ref cmd, model.ProCheckInfo, rptID, model.ProReport.PROID, model.ProReport.REGINFOID))
                                num++;
                        }
                        else
                            num++;
                    }

                    if (num == 4)
                    {
                        tran.Commit();
                        flag = true;
                    }
                    else
                    {
                        tran.Rollback();
                       
                    }
                    
                }
                catch (Exception ex)
                {
                    log.ExceptionHand(ex);
                    tran.Rollback();
                }
                finally
                {
                    cmd.Dispose();
                    tran.Dispose();
                    con.Close();
                    con.Dispose();
                }
            
            }

            return flag;
        }

        /// <summary>
        ///  调查报告新增
        /// </summary>
        private long AddReport(ref OracleCommand cmd, GSLMS.Entity.TB_APP_PROREPORTINFO model)
        {
            long num = 0;
            string CREATEDATE = "";
            CREATEDATE = model.CREATEDATE == null ? "" : ((DateTime)model.CREATEDATE).ToString("yyyy-MM-dd");
            OracleParameter[] parms = new OracleParameter[]{
								new OracleParameter("P_ID", model.ID),
								new OracleParameter("P_PROID", model.PROID),
								new OracleParameter("P_REGINFOID", model.REGINFOID),
								new OracleParameter("P_BUSSDETAIL", model.BUSSDETAIL??""),
								new OracleParameter("P_REGDETAIL", model.REGDETAIL??""),
								new OracleParameter("P_CORPNAME", model.CORPNAME??""),
								new OracleParameter("P_CREATEDATE", CREATEDATE),
								new OracleParameter("P_REGCAPTAIL", model.REGCAPTAIL),
								new OracleParameter("P_LEGALMAN", model.LEGALMAN??""),
								new OracleParameter("P_BUSSTERM", model.BUSSTERM),
								new OracleParameter("P_LOANNO", model.LOANNO??""),
								new OracleParameter("P_CONBY", model.CONBY??""),
								new OracleParameter("P_ANNCHECK", model.ANNCHECK??""),
								new OracleParameter("P_REGADDR", model.REGADDR??""),
								new OracleParameter("P_REGADDRTYPE", model.REGADDRTYPE??""),
								new OracleParameter("P_REGTELCODE", model.REGTELCODE??""),
								new OracleParameter("P_REGTEL", model.REGTEL??""),
								new OracleParameter("P_REGTELSUB", model.REGTELSUB??""),
								new OracleParameter("P_WORKADDR", model.WORKADDR??""),
								new OracleParameter("P_WORKTELCODE", model.WORKTELCODE??""),
								new OracleParameter("P_WORKTEL", model.WORKTEL??""),
								new OracleParameter("P_WORKTELSUB", model.WORKTELSUB??""),
								new OracleParameter("P_ISSPECAILCER", model.ISSPECAILCER),
								new OracleParameter("P_HAVESPECAILCERS", model.HAVESPECAILCERS??""),
								new OracleParameter("P_LEGALHOUADDR", model.LEGALHOUADDR??""),
								new OracleParameter("P_LEGALADDR", model.LEGALADDR??""),
								new OracleParameter("P_LEGALTEL", model.LEGALTEL??""),
								new OracleParameter("P_LEGALTEL2", model.LEGALTEL2??""),
								new OracleParameter("P_CONBYADDR", model.CONBYADDR??""),
								new OracleParameter("P_CONBYTEL", model.CONBYTEL??""),
								new OracleParameter("P_CONBYTEL2", model.CONBYTEL2??""),
								new OracleParameter("P_OTHERREMARK", model.OTHERREMARK??""),
								new OracleParameter("P_SURVEYBY", model.SURVEYBY??""),
								new OracleParameter("P_SURVEYTIME", model.SURVEYTIME),
								new OracleParameter("P_STATUS", model.STATUS),
								new OracleParameter("P_SPAREFIELD1", model.SPAREFIELD1),
								new OracleParameter("P_SPAREFIELD2", model.SPAREFIELD2??""),
								new OracleParameter("P_SPAREFIELD3", model.SPAREFIELD3??""),
                                new OracleParameter("returnvalue", OracleType.Number)
                   };

            for (int i = 0; i < 38; i++)
            {
                parms[i].Direction = ParameterDirection.Input;
            }

            parms[38].Direction = ParameterDirection.Output;

            try
            {
                cmd.Parameters.Clear();
                cmd.Parameters.AddRange(parms);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "pkg_apply.proc_proreportinfo_add";
                cmd.ExecuteNonQuery();

                if (parms[38].Value != DBNull.Value)
                    num = OracleHelper.ToLong(parms[38].Value.ToString());
                
            }
            catch (Exception ex)
            {
                log.ExceptionHand(ex);
            }

            return num;
        }

        /// <summary>
        ///  调查报告股东信息新增
        /// </summary>
        private bool AddReportSHinfo(ref OracleCommand cmd, List<GSLMS.Entity.TB_APP_PROREPORTSHINFO> list, long rptID,long proID,long regID)
        {
            bool flag = false;
            if (list != null && list.Count > 0)
            {

                foreach (var model in list)
                {
                    OracleParameter[] parms = new OracleParameter[]{
								new OracleParameter("P_ID", model.ID),
								new OracleParameter("P_REGINFOID",regID),
								new OracleParameter("P_PROID",proID),
								new OracleParameter("P_REPORTID", rptID),
								new OracleParameter("P_NAME", model.NAME??""),
								new OracleParameter("P_ADDRESS", model.ADDRESS??""),
								new OracleParameter("P_TEL", model.TEL??""),
								new OracleParameter("P_FUNDED", model.FUNDED??""),
								new OracleParameter("P_AMOUNT", model.AMOUNT),
								new OracleParameter("P_RATIO", model.RATIO),
								new OracleParameter("P_ISPAYED", model.ISPAYED),
								new OracleParameter("P_SPAREFIELD1", model.SPAREFIELD1),
								new OracleParameter("P_SPAREFIELD2", model.SPAREFIELD2??""),
								new OracleParameter("P_SPAREFIELD3", model.SPAREFIELD3??"")};

                    for (int i = 0; i < 14; i++)
                    {
                        parms[i].Direction = ParameterDirection.Input;
                    }

                    cmd.Parameters.Clear();
                    cmd.Parameters.AddRange(parms);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = "pkg_apply.proc_proreportshinfo_add";
                    int effRow = cmd.ExecuteNonQuery();
                    if (effRow != 1)
                    {
                        return false;
                    }
                   
                }
                flag = true;
            }
            return flag;
        }


        /// <summary>
        ///  调查报告调查对象信息新增
        /// </summary>
        private bool AddCheckObjInfo(ref OracleCommand cmd, List<GSLMS.Entity.TB_APP_PROCHECKOBJINFO> list, long rptID,long proID,long regID)
        {
            bool flag = false;
            if (list != null && list.Count > 0)
            {
                foreach (var model in list)
                {
                    OracleParameter[] parms = new OracleParameter[]{
								new OracleParameter("P_ID", model.ID),
								new OracleParameter("P_REGINFOID", regID),
								new OracleParameter("P_PROID", proID),
								new OracleParameter("P_REPORTID", rptID),
								new OracleParameter("P_SURVEYOBJ", model.SURVEYOBJ??""),
								new OracleParameter("P_SURVEYTIME", model.SURVEYTIME),
								new OracleParameter("P_OWNERSURVEYBY", model.OWNERSURVEYBY??""),
								new OracleParameter("P_COUNTBY", model.COUNTBY??""),
								new OracleParameter("P_COUNTBYIND", model.COUNTBYIND??""),
								new OracleParameter("P_SPAREFIELD1", model.SPAREFIELD1),
								new OracleParameter("P_SPAREFIELD2", model.SPAREFIELD2??""),
								new OracleParameter("P_SPAREFIELD3", model.SPAREFIELD3??"")};

                    for (int i = 0; i < 12; i++)
                    {
                        parms[i].Direction = ParameterDirection.Input;
                    }

                    cmd.Parameters.Clear();
                    cmd.Parameters.AddRange(parms);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = "pkg_apply.proc_procheckobjinfo_add";
                    int effRow = cmd.ExecuteNonQuery();
                    if (effRow != 1)
                    {
                        return false;
                    }

                    
                }
                flag = true;
            }
            return flag;
        }

        /// <summary>
        ///  调查报告调查项信息新增
        /// </summary>
        private bool AddCheckInfo(ref OracleCommand cmd, List<GSLMS.Entity.TB_APP_PROCHECKINFO> list, long rptID,long proID,long regID)
        {
            bool flag = false;

            if (list != null && list.Count > 0)
            {

                foreach (var model in list)
                {
                    OracleParameter[] parms = new OracleParameter[]{
								new OracleParameter("P_ID", model.ID),
								new OracleParameter("P_REGINFOID", regID),
								new OracleParameter("P_PROID",proID),
								new OracleParameter("P_REPORTID", rptID),
								new OracleParameter("P_PROCODE", model.PROCODE??""),
								new OracleParameter("P_PRONAME", model.PRONAME??""),
								new OracleParameter("P_SURCONTEN", model.SURCONTEN??""),
								new OracleParameter("P_SORTNO", model.SORTNO),
								new OracleParameter("P_SPAREFIELD1", model.SPAREFIELD1),
								new OracleParameter("P_SPAREFIELD2", model.SPAREFIELD2??""),
								new OracleParameter("P_SPAREFIELD3", model.SPAREFIELD3??"")};

                    for (int i = 0; i < 11; i++)
                    {
                        parms[i].Direction = ParameterDirection.Input;
                    }

                    cmd.Parameters.Clear();
                    cmd.Parameters.AddRange(parms);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = "pkg_apply.proc_procheckinfo_add";
                    int effRow = cmd.ExecuteNonQuery();
                    if (effRow != 1)
                    {
                        return false;
                    }

                }

                flag = true;
                
            }

            return flag;
        }


        /// <summary>
        /// 审批退回
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool AduitBackTo(GSLMS.Entity.TB_APP_PROINFO model)
        {
            bool flag = false;

            OracleParameter[] parms = new OracleParameter[] { 
              new OracleParameter("p_proid",model.ID),
              new OracleParameter("p_backby",model.BACKBY??""),
              new OracleParameter("p_backreason",model.BACKREASON),
              new OracleParameter("returnvalue",OracleType.Int32)
            };

            parms[0].Direction = ParameterDirection.Input;
            parms[1].Direction = ParameterDirection.Input;
            parms[2].Direction = ParameterDirection.Input;
            parms[3].Direction = ParameterDirection.Output;

            try
            {
                OracleHelper.ExecuteNonQuery(OracleHelper.connectionString, CommandType.StoredProcedure, "pkg_audit.proc_audit_backto", parms);
                if (parms[3].Value != DBNull.Value && OracleHelper.ToInt(parms[3].Value.ToString()) == 1)
                    flag = true;
            }
            catch (Exception ex)
            {
                log.ExceptionHand(ex);
            }
                

            return flag;
        }
        

		#endregion  Method
	}
}

